home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / vdl020d.zip / VMATH.DOC < prev    next >
Text File  |  1993-04-14  |  80KB  |  4,006 lines

  1. {
  2.  ════════════════════════════════════════════════════════════════════════════
  3.  
  4.  Visionix Math Functions Unit (VMATH)
  5.  Copyright 1991,92,93 Visionix
  6.  ALL RIGHTS RESERVED
  7.  
  8.  ────────────────────────────────────────────────────────────────────────────
  9.  
  10.  Revision history in reverse chronological order:
  11.  
  12.  Initials  Date      Comment
  13.  --------  --------  --------------------------------------------------------
  14.  
  15.  mep       03/25/93  Fixed ArcSin, ArcCos, ArcCsc, ArcSec, ArcCot, and
  16.                        Factorial.
  17.                      Cleaned up code.
  18.  mep       02/11/93  Cleaned up code for beta release
  19.  jrt       02/08/93  Sync with beta 0.12
  20.  mep       02/02/93  Changed hyberbolic function names to be more proper.
  21.                      Cleanup of code for release (with more notes).
  22.                      Added: DistanceXY, QuadraticPlus, QuadraticNeg,
  23.                        Factorial, Permu, Combo, DegToRad, GradToRad,
  24.                        DegToGrad, RadToDeg, RadToGrad, GradToDeg, GCF,
  25.                        LCM.
  26.  lpg       01/13/92  Added: Sin2,Cos2
  27.                      Also wrote up quick Trig Info for header
  28.  lpg       01/13/92  Renamed Clamp functions to Range
  29.  jrt       12/07/92  Sync with beta 0.11 release
  30.  jrt       11/21/92  Sync with beta 0.08
  31.  lpg       11/08/92  Added more function:  all Hyp and Arc series.
  32.  lpg       10/05/92  First logged revision.
  33.  
  34.  ----------------------------------------------------------------------------
  35.  
  36.  Caveats/Known Bugs
  37.  
  38.  
  39.      The following Functions are incomplete and simply return Zero:
  40.  
  41.        ArcCsc, ArcSec and ArcCot
  42.  
  43.      Data was not available at this time to complete these.
  44.  
  45.  ----------------------------------------------------------------------------
  46.  
  47.  ════════════════════════════════════════════════════════════════════════════
  48. }
  49.  
  50. (*
  51.  
  52. Definitions of Terms
  53. --------------------
  54.  
  55. TRIGONOMETRY - The branch of mathematics that deals with the relations
  56.   between the sides and angles of pnae of spherical triangles, and the
  57.   calculations based upon them.  [<NL trigonometria, lit., "triangle
  58.   measuring"]
  59.  
  60. RADIAN - An angle at the center of a circle, subtending an arc of
  61.   the circle equal in length to the radius.  A length of the circle's
  62.   radius measured across a circle's circumference and measured in
  63.   angles from the circle's center. 1 Radian = 57.2958 degrees.
  64.   3.14159 Radians = 360 degrees.  [Radi(us) + an]
  65.  
  66. HYPOTENUSE - The side of a right triangle opposite the right angle.
  67.  
  68. QUADRANT - A quarter of a circle.  [ME<L quadrant-(s. of quadrans)
  69.   4th part]
  70.  
  71. e (base of the natural logarithms) is approximately 2.718;
  72.  
  73. π (pi) is approximately 3.14159
  74.  
  75. Θ = Angle Theta (General reference angle)
  76.  
  77. ∞ = Infinity
  78.  
  79. │x│ = Absolute value of x
  80.  
  81. √x = Square root of x
  82.  
  83. x^n = x raised to the n power
  84.  
  85. ln(x) = Natural logarithm of x
  86.  
  87.  
  88.  
  89.  
  90. GRAPHS OF THE UNIT CIRCLE
  91. =========================
  92.  
  93.  
  94. I. QUADRANT SYSTEM
  95. ------------------
  96.  
  97.     R = Radius of Circle (here 1 unit)
  98.  
  99.  
  100.                      +Y
  101.                       .
  102.                       .
  103.                       .(0,1)
  104.                  .....*......
  105.                ..     .      .. B
  106.               .       .        +
  107. Quadrant 2   .        .       /|.   Quadrant 1
  108.             .         .      / | .
  109.            .          .     /  |  .
  110.           .           .  R /   |   .
  111.           .           .   /   a|   .
  112.          .            .  / c   |    .
  113.          .            . /      |    .
  114.    (-1,0).           A./   b   |C   .(1,0)
  115. -X ......*............+--------+....*..... +X
  116.          .       (0,0).             .
  117.          .      Origin.             .
  118.          .            .             .
  119.           .           .            .
  120.           .           .            .
  121.            .          .           .
  122.             .         .          .
  123. Quadrant 3   .        .         .   Quadrant 4
  124.               .       .        .
  125.                ..     .     ..
  126.                  .....*.....
  127.                       .(0,-1)
  128.                       .
  129.                       .
  130.                      -Y
  131.  
  132.  
  133.  
  134. II. RADIANS AND DEGREES
  135. -----------------------
  136.  
  137.                 π/2
  138.           2π/3        π/3
  139.              ....*....
  140.     3π/4  ..*         *..   π/4
  141.          .               .
  142.         *        90       *
  143.        .    120  .   60    .
  144.       .          .          .
  145. 5π/6 .   135     .     45    . π/6
  146.      *           .           *
  147.     .  150       .        30  .
  148.     .            .            .
  149.     .            .            .
  150.     .            .            .
  151.  π  * 180 .......+......... 0 *  0
  152.     .            .            .
  153.     .            .            .
  154.     .            .            .
  155.     .  210       .       330  .
  156.      *           .           *
  157. 7π/6 .           .           . 11π/6
  158.       .  225     .     315  .
  159.        .         .         .
  160.         *   240     300   *
  161.          .      270      .
  162.     5π/4  ..           ..  7π/4
  163.             *....*....*
  164.  
  165.           4π/3       5π/3
  166.                 3π/2
  167.  
  168.  
  169.  
  170. III. CIRCULAR FUNCTION DEFINITIONS
  171. ----------------------------------
  172.  
  173.                 Y
  174.                 .
  175.                 .
  176.  
  177.             .........
  178.     (x,y)...         ...
  179.         .       .       .
  180.        *        .        .
  181.       .|\       .         .
  182.      . | \  r   .          .
  183.     .  |  \     .           .        Where Θ is any angle:
  184.     .  |   \                .
  185.    .  y|    \   __           .        sin Θ = y / r
  186.    .   |     \ /  \          .
  187.    .   |      \  Θ \         .        cos Θ = x / r
  188.    .   |       \   |         .
  189. .. . ..---------+ .......... . ..X    tan Θ = y / x
  190.    .       x                 .
  191.    .            .            .        csc Θ = r / y
  192.    .            .            .
  193.    .            .            .        sec Θ = r / x
  194.     .           .           .
  195.     .           .           .         cot Θ = x / y
  196.      .          .          .
  197.       .         .         .
  198.        .        .        .
  199.         .       .       .
  200.          ..           ..
  201.            ...........
  202.  
  203.                 .
  204.                 .
  205.  
  206.  
  207. IV. SINE/COSINE RELATIONSHIPS
  208. -----------------------------
  209.  
  210.   On unit circles, (x, y) = (cos, sin)
  211.  
  212.  
  213.                         (0, 1)
  214.  
  215.                            .
  216.             (-1/2, √3/2)   .   (1/2, √3/2)
  217.  
  218.                        ....*....
  219.     (-√2/2, √2/2)   ..*         *..  (√2/2, √2/2)
  220.                    .       .       .
  221.                   *        .        *
  222.                  .         .         .
  223.   (√3/2, 1/2)   .          .          .  (√3/2, 1/2)
  224.                .           .           .
  225.                *           .           *
  226.               .     II     .     I      .
  227.               .            .            .
  228.               .            .            .
  229.               .            .            .
  230. (-1, 0) ..... * ...........+........... * ..... (1, 0)
  231.               .            .            .
  232.               .            .            .
  233.               .            .            .
  234.               .            .            .
  235.                *    III    .     IV    *
  236.                .           .           .
  237.   (-√3/2, -1/2) .          .          .  (√3/2, -1/2)
  238.                  .         .         .
  239.                   *        .        *
  240.                    .       .       .
  241.     (-√2/2, -√2/2)  ..           ..  (√2/2, -√2/2)
  242.                       *....*....*
  243.  
  244.             (-1/2, -√3/2)  .  (1/2, -√3/2)
  245.                            .
  246.  
  247.                         (0, -1)
  248.  
  249.  
  250.  
  251.   In quadrant I,   ALL trig. functions are positive.
  252.   In quadrant II,  only SIN and CSC are positive.
  253.   In quadrant III, only TAN and COT are positive.
  254.   In quadrant IV,  only COS and SEC are positive.
  255.  
  256.  
  257.  
  258.  
  259.  
  260. Definition of the Six Trigonometric Functions
  261. ---------------------------------------------
  262. (Right triangle definitions, where 0 < Θ < π/2)
  263.  
  264.           e
  265.          s +    sin Θ = Opp / Hyp
  266.         u /|O
  267.        n / |p   cos Θ = Adj / Hyp
  268.       e /  |p
  269.      t /   |o   tan Θ = Opp / Adj
  270.     o /    |s
  271.    p /     |i   csc Θ = 1 / sin Θ = Hyp / Opp
  272.   y /      |t
  273.  H / Θ     |e   sec Θ = 1 / cos Θ = Hyp / Adj
  274.   +--------+
  275.    Adjacent     cot Θ = 1 / tan Θ = Adj / Opp
  276.  
  277.  
  278.  
  279. Definition of Inverse Trigonometric Functions
  280. ---------------------------------------------
  281.  
  282. Function                     Domain         Range
  283. --------------------------   ------------   ----------------
  284.  
  285. y = arcsin x iff sin y = x   -1 <= x <= 1   -π/2 <= y <= π/2
  286.  
  287. y = arccos x iff cos y = x   -1 <= x <= 1   0 <= y <= π
  288.  
  289. y = arctan x iff tan y = x   -∞ < x < ∞     -π/2 < y < π/2
  290.  
  291. y = arccot x iff cot y = x   -∞ < x < ∞     0 < y < π
  292.  
  293. y = arcsec x iff sec y = x   │x│ >= 1       0 <= y <= π, y <> π/2
  294.  
  295. y = arccsc x iff csc y = x   │x│ >= 1       -π/2 <= y <= π/2, y <> 0
  296.  
  297.  
  298.  
  299. Definition of the Hyberbolic Functions
  300. --------------------------------------
  301.  
  302. Function                   Domain               Range
  303. -------------------------  ------------------   ------------------
  304.  
  305. sinh x = (e^x - e^-x) / 2  -∞ < x < ∞           -∞ < y < ∞
  306.  
  307. cosh x = (e^x + e^-x) / 2  -∞ < x < ∞           -1 <= y < ∞
  308.  
  309. tanh x = sinh x / cosh x   -∞ < x < ∞           -1 < y < 1
  310.  
  311. csch x = 1 / sinh x,       -∞ < x < ∞, x <> 0   -∞ < y < ∞, y <> 0
  312.  
  313. sech x = 1 / cosh x        -∞ < x < ∞           0 < y <= 1
  314.  
  315. coth x = 1 / tanh x,       -∞ < x < ∞, x <> 0   -∞ < y < -1,
  316.                                                  1 < y < ∞
  317.  
  318.  
  319.  
  320. Definition of the Inverse Hyperbolic Functions
  321. ----------------------------------------------
  322.  
  323. Function                                      Domain       Range
  324. -------------------------------------------   ----------   ---------
  325.  
  326. arcsinh x = ln( x + √(x^2 + 1) )              -∞ < x < ∞   -∞ < y < ∞
  327.  
  328. arccosh x = ln( x + √(x^2 - 1) )              1 <= x < ∞   ∞ <= y < ∞
  329.  
  330. arctanh x = (1/2) * ln( (1 + x) / (1 - x) )   │x│ < 1      ∞ <= y < ∞
  331.  
  332. arccoth x = (1/2) * ln( (x + 1) / (x - 1) )   │x│ > 1      -∞ < y < ∞, y <> 0
  333.  
  334. arcsech x = ln( (1 + √(1 - x^2)) / x )        0 < x <= 1   0 <= y < ∞
  335.  
  336. arccsch x = ln( (1 + √(1 + x^2)) / │x│ )      x > 0        -∞ < y < ∞, y <> 0
  337.  
  338.           = ln( (-1 + √(1 + x^2)) / │x│ )     x < 0
  339.  
  340.  
  341. *)
  342.  
  343. {────────────────────────────────────────────────────────────────────────────}
  344.  
  345.  
  346. Unit VMath;
  347.  
  348.  
  349.  
  350.  
  351.   {------------------------------------}
  352.   { Constants and type definitions     }
  353.   {------------------------------------}
  354.  
  355. Const
  356.  
  357.   cINFINITY  = 9.9999999999E+37;  {or 5.5E11, also 65000 for INTEGER}
  358.   cOVERFLOW  = 9.9999999999E+37;
  359.   cUNDERFLOW = 1.0E-37;
  360.  
  361.   cTolerance = 0.00000001;        {for math error tolerances}
  362.  
  363. TYPE
  364.  
  365.   { Linear Array }
  366.   TArrayR   = ARRAY[1..1] of REAL;
  367.   PArrayR   = ^TArrayR;
  368.  
  369.   TArrayRA  = ARRAY[1..100] of REAL;
  370.   PArrayRA  = ^TArrayRA;
  371.  
  372.   { Coordinate Array - Maps over Linear Array }
  373.   TRec2R    = RECORD
  374.     X : REAL;
  375.     Y : REAL;
  376.   END;
  377.   TArray2R  = Array[1..1] of TRec2R;
  378.   PArray2R  = ^TArray2R;
  379.  
  380.   TArray2RA = Array[1..100] of TRec2R;
  381.   PArray2RA = ^TArray2RA;
  382.  
  383.  
  384.   {------------------------------------}
  385.   { Procedure and function definitions }
  386.   {------------------------------------}
  387.  
  388.  
  389.   {-------------------}
  390.   { Type Converstions }
  391.   {-------------------}
  392.  
  393. Function  HMStoDegrees(      Degs      : WORD;
  394.                              Mins      : WORD;
  395.                              Secs      : REAL         ) : REAL;
  396.  
  397. Procedure DegreesToHMS(      Degrees   : REAL;
  398.                          Var Degs      : INTEGER;
  399.                          Var Min       : INTEGER;
  400.                          Var Sec       : REAL         );
  401.  
  402. Function  DegToRad(          Deg       : REAL         ) : REAL;
  403.  
  404. Function  GradToRad(         Grad      : REAL         ) : REAL;
  405.  
  406. Function  DegToGrad(         Deg       : REAL         ) : REAL;
  407.  
  408. Function  RadToDeg(          Rad       : REAL         ) : REAL;
  409.  
  410. Function  RadToGrad(         Rad       : REAL         ) : REAL;
  411.  
  412. Function  GradToDeg(         Grad      : REAL         ) : REAL;
  413.  
  414. {----------------}
  415. { Trig Functions }
  416. {----------------}
  417.  
  418. Function  Quad(              Radians   : REAL         ) : INTEGER;
  419.  
  420. Function  Quad2(             X, Y      : REAL         ) : INTEGER;
  421.  
  422. Function  Sin2(              X, Y      : REAL         ) : REAL;
  423.  
  424. Function  Cos2(              X, Y      : REAL         ) : REAL;
  425.  
  426. Function  Tan(               X         : REAL         ) : REAL;
  427.  
  428. Function  Tan2(              X, Y      : REAL         ) : REAL;
  429.  
  430. Function  Cot(               X         : REAL         ) : REAL;
  431.  
  432. Function  Cot2(              X, Y      : REAL         ) : REAL;
  433.  
  434. Function  Csc(               X         : REAL         ) : REAL;
  435.  
  436. Function  Sec(               X         : REAL         ) : REAL;
  437.  
  438. Function  Sinh(              X         : REAL         ) : REAL;  {NOT TESTED}
  439.  
  440. Function  Cosh(              X         : REAL         ) : REAL;
  441.  
  442. Function  Tanh(              X         : REAL         ) : REAL;
  443.  
  444. Function  Csch(              X         : REAL         ) : REAL;  {NOT TESTED}
  445.  
  446. Function  Sech(              X         : REAL         ) : REAL;  {NOT TESTED}
  447.  
  448. Function  Coth(              X         : REAL         ) : REAL;  {NOT TESTED}
  449.  
  450. Function  ArcSin(            X         : REAL         ) : REAL;
  451.  
  452. Function  ArcSin2(           X         : REAL;
  453.                              Quadrant  : INTEGER      ) : REAL;
  454.  
  455. Function  ArcCos(            X         : REAL         ) : REAL;
  456.  
  457. Function  ArcCos2(           X         : REAL;
  458.                              Quadrant  : INTEGER      ) : REAL;
  459.  
  460. Function  ArcTan1(           X         : REAL         ) : REAL;
  461.  
  462. Function  ArcTan2(           X, Y      : REAL         ) : REAL;
  463.  
  464. Function  ArcCsc(            X         : REAL         ) : REAL; {NOT TESTED}
  465.  
  466. Function  ArcSec(            X         : REAL         ) : REAL;  {NOT TESTED}
  467.  
  468. Function  ArcCot(            X         : REAL         ) : REAL;  {NOT TESTED}
  469.  
  470. Function  ArcSinh(           X         : REAL         ) : REAL;
  471.  
  472. Function  ArcCosh(           X         : REAL         ) : REAL;
  473.  
  474. Function  ArcTanh(           X         : REAL         ) : REAL;
  475.  
  476. Function  ArcCsch(           X         : REAL         ) : REAL;
  477.  
  478. Function  ArcSech(           X         : REAL         ) : REAL;
  479.  
  480. Function  ArcCoth(           X         : REAL         ) : REAL;
  481.  
  482. {----------------------}
  483. { Basic Math Functions }
  484. {----------------------}
  485.  
  486. Function  Power(             Num       : LONGINT;
  487.                              Exponent  : LONGINT      ) : LONGINT;
  488.  
  489. Function  PowerR(            Num       : REAL;
  490.                              Exponent  : REAL         ) : REAL;
  491.  
  492. Function  Root(              Num       : LONGINT;
  493.                              RootVal   : LONGINT      ) : LONGINT;
  494.  
  495. Function  RootR(             Num       : REAL;
  496.                              RootVal   : REAL         ) : REAL;
  497.  
  498. Function  Log(               Num       : REAL;
  499.                              Base      : REAL         ) : REAL;
  500.  
  501. Function FastHyp(            XDist     : REAL;
  502.                            YDist     : REAL        ) : REAL;
  503.  
  504. Function FastHypR(           XDist     : REAL;
  505.                            YDist     : REAL        ) : REAL;
  506.  
  507. Function Hypot(              XDist     : REAL;
  508.                            YDist     : REAL        ) : REAL;
  509.  
  510. Function FastDist(           X1        : LONGINT;
  511.                            Y1        : LONGINT;
  512.                            X2        : LONGINT;
  513.                            Y2        : LONGINT      ) : LONGINT;
  514.  
  515. Function DistanceXY(         X1        : REAL;
  516.                            Y1        : REAL;
  517.                            X2        : REAL;
  518.                            Y2        : REAL         ) : REAL;
  519.  
  520. Function Percent(            Part      : LONGINT;
  521.                            Whole     : LONGINT      ) : REAL;
  522.  
  523. Function Min(                A         : LONGINT;
  524.                            B         : LONGINT      ) : LONGINT;
  525.  
  526. Function MinR(               A         : REAL;
  527.                            B         : REAL         ) : REAL;
  528.  
  529. Function  Max(               A         : LONGINT;
  530.                              B         : LONGINT      ) : LONGINT;
  531.  
  532. Function  MaxR(              A         : REAL;
  533.                              B         : REAL         ) : REAL;
  534.  
  535. Function  Range(             Num       : LONGINT;
  536.                              Low       : LONGINT;
  537.                              High      : LONGINT      ) : LONGINT;
  538.  
  539. Function  RangeR(            Num       : REAL;
  540.                              Low       : REAL;
  541.                              High      : REAL         ) : REAL;
  542.  
  543. Function  Floor(             Num       : LONGINT;
  544.                              Low       : LONGINT      ) : LONGINT;
  545.  
  546. Function  FloorR(            Num       : REAL;
  547.                              Low       : REAL         ) : REAL;
  548.  
  549. Function  Ceiling(           Num       : LONGINT;
  550.                              High      : LONGINT      ) : LONGINT;
  551.  
  552. Function  CeilingR(          Num       : REAL;
  553.                              High      : REAL         ) : REAL;
  554.  
  555. Function  Sign(              Num       : LONGINT      ) : INTEGER;
  556.  
  557. Function  SignR(             Num       : REAL         ) : INTEGER;
  558.  
  559.  
  560. {-----------------------}
  561. { Higher Math Functions }
  562. {-----------------------}
  563.  
  564. Function  QuadraticPlus(     A         : LONGINT;
  565.                              B         : LONGINT;
  566.                              C         : LONGINT      ) : REAL;
  567.  
  568. Function  QuadraticNeg(      A         : LONGINT;
  569.                              B         : LONGINT;
  570.                              C         : LONGINT      ) : REAL;
  571.  
  572. Function  Factorial(         N         : BYTE         ) : REAL;
  573.  
  574. Function  Permu(             N         : BYTE;
  575.                              R         : BYTE         ) : REAL;
  576.  
  577. Function  Combo(             N         : BYTE;
  578.                              R         : BYTE         ) : REAL;
  579.  
  580. Function  Prime(             N         : LONGINT      ) : BOOLEAN;
  581.  
  582. Function  GCF(               A         : LONGINT;
  583.                              B         : LONGINT      ) : LONGINT;
  584.  
  585. Function  LCM(               A         : LONGINT;
  586.                              B         : LONGINT      ) : LONGINT;
  587.  
  588. Procedure LoadArrayR(    VAR Arr       : PArrayR;
  589.                              Idx       : WORD;
  590.                              R         : REAL         );
  591.  
  592. Procedure LoadArrayRXY(  VAR Arr       : PArray2R;
  593.                              Idx       : WORD;
  594.                              X         : REAL;
  595.                              Y         : REAL         );
  596.  
  597. Procedure MeanStdDev(        Arr       : PArrayR;
  598.                              Cnt       : INTEGER;
  599.                          VAR Mean      : REAL;
  600.                          VAR StdDev    : REAL         );
  601.  
  602. Function  Sigma(             Arr       : PArrayR;
  603.                              Cnt       : INTEGER      ) : REAL;
  604.  
  605. Procedure LeastSqr(          Arr       : PArray2R;
  606.                              Cnt       : INTEGER;
  607.                          VAR YInt      : REAL;
  608.                          VAR Slope     : REAL         );
  609.  
  610.   {------------------------------}
  611.   { Begin implementation of code }
  612.   {------------------------------}
  613.  
  614.  
  615. ──────────────────────────────────────────────────────────────────────────────
  616.  
  617.  
  618. [FUNCTION]
  619.  
  620. Function HMStoDegrees(       Degs      : WORD;
  621.                              Mins      : WORD;
  622.                              Secs      : REAL         ) : REAL;
  623.  
  624. [PARAMETERS]
  625.  
  626. Degs        Arc Degrees
  627. Mins        Arc Minutes
  628. Secs        Arc Seconds
  629.  
  630. [RETURNS]
  631.  
  632. Floating Point Decimal Degrees
  633.  
  634. [DESCRIPTION]
  635.  
  636. Converts Arc Degrees, Minutes and Seconds into a Floating Point
  637. Degree Value.
  638.  
  639. [SEE-ALSO]
  640.  
  641. DegreesToHMS
  642.  
  643. [EXAMPLE]
  644.  
  645. BEGIN
  646.  
  647.   WriteLn( HMStoDegrees( 59, 30, 0 ):8:4 );
  648.  
  649. END;
  650.  
  651.  
  652. ──────────────────────────────────────────────────────────────────────────────
  653.  
  654.  
  655. [FUNCTION]
  656.  
  657. Procedure DegreesToHMS(      Degrees   : REAL;
  658.                          Var Degs      : INTEGER;
  659.                          Var Min       : INTEGER;
  660.                          Var Sec       : REAL         );
  661.  
  662. [PARAMETERS]
  663.  
  664. Degrees     Floating Point Angle in Degrees
  665. Degs        VAR Returned Arc Degrees
  666. Min         VAR Returned Arc Minutes
  667. Sec         VAR Returned Arc Seconds
  668.  
  669. [RETURNS]
  670.  
  671. (Function : None)
  672. (VAR      : [Degs] Arc Degrees)
  673. (VAR      : [Min ] Arc Minutes)
  674. (VAR      : [Sec ] Arc Seconds)
  675.  
  676. [DESCRIPTION]
  677.  
  678. Converts a Floating Point Angle in Degrees into the Component
  679. Parts of Arc (Degrees, Minutes and Seconds)
  680.  
  681. [SEE-ALSO]
  682.  
  683. [EXAMPLE]
  684.  
  685. VAR
  686.   D,M,S : REAL;
  687.  
  688. BEGIN
  689.  
  690.   DegreesToHMS( 45.6137, D,M,S );
  691.  
  692.   WriteLn( 'Deg = ',Deg:2:0 );
  693.   WriteLn( 'Min = ',Min:2:0 );
  694.   WriteLn( 'Sec = ',Sec:5:2 );
  695.  
  696. END;
  697.  
  698.  
  699. ──────────────────────────────────────────────────────────────────────────────
  700.  
  701.  
  702. [FUNCTION]
  703.  
  704. Function DegToRad(           Deg       : REAL         ) : REAL;
  705.  
  706. [PARAMETERS]
  707.  
  708. Deg         Floating Point Angle in Degrees
  709.  
  710. [RETURNS]
  711.  
  712. Angle in Radians
  713.  
  714. [DESCRIPTION]
  715.  
  716. Converts Arc Degrees to Radians.
  717.  
  718. [SEE-ALSO]
  719.  
  720. DegToGrad
  721. RadToDeg
  722. RadToGrad
  723. GradToDeg
  724. GradToRad
  725.  
  726. [EXAMPLE]
  727.  
  728. VAR
  729.   Rad : REAL;
  730.  
  731. BEGIN
  732.  
  733.   Rad := DegToRad(   0.0 );  { Rad = 0.0000 }
  734.   Rad := DegToRad(  30.0 );  { Rad = 0.5236 }
  735.   Rad := DegToRad(  45.0 );  { Rad = 0.7854 }
  736.   Rad := DegToRad(  90.0 );  { Rad = 1.5708 }
  737.   Rad := DegToRad( 180.0 );  { Rad = 3.1416 }
  738.   Rad := DegToRad( 360.0 );  { Rad = 6.2832 }
  739.  
  740. END;
  741.  
  742.  
  743. ──────────────────────────────────────────────────────────────────────────────
  744.  
  745.  
  746. [FUNCTION]
  747.  
  748. Function DegToGrad(          Deg       : REAL         ) : REAL;
  749.  
  750. [PARAMETERS]
  751.  
  752. Deg         Angle in Degrees
  753.  
  754. [RETURNS]
  755.  
  756. Angle in Gradients
  757.  
  758. [DESCRIPTION]
  759.  
  760. Converts Arc Degrees to Gradients
  761.  
  762. [SEE-ALSO]
  763.  
  764. DegToRad
  765. RadToDeg
  766. RadToGrad
  767. GradToDeg
  768. GradToRad
  769.  
  770. [EXAMPLE]
  771.  
  772. VAR
  773.   Grad : REAL;
  774.  
  775. BEGIN
  776.  
  777.   Grad := DegToGrad(   0.0 );  { Grad =   0.0000 }
  778.   Grad := DegToGrad(  30.0 );  { Grad =  33.3333 }
  779.   Grad := DegToGrad(  45.0 );  { Grad =  50.0000 }
  780.   Grad := DegToGrad(  90.0 );  { Grad = 100.0000 }
  781.   Grad := DegToGrad( 180.0 );  { Grad = 200.0000 }
  782.   Grad := DegToGrad( 360.0 );  { Grad = 400.0000 }
  783.  
  784. END;
  785.  
  786.  
  787. ──────────────────────────────────────────────────────────────────────────────
  788.  
  789.  
  790. [FUNCTION]
  791.  
  792. Function RadToDeg(           Rad       : REAL         ) : REAL;
  793.  
  794. [PARAMETERS]
  795.  
  796. Rad         Angle in Radians
  797.  
  798. [RETURNS]
  799.  
  800. Angle in Degrees
  801.  
  802. [DESCRIPTION]
  803.  
  804. Converts Arc Radians to Degrees
  805.  
  806. [SEE-ALSO]
  807.  
  808. DegToRad
  809. DegToGrad
  810. RadToGrad
  811. GradToDeg
  812. GradToRad
  813.  
  814. [EXAMPLE]
  815.  
  816. VAR
  817.   Deg : REAL;
  818.  
  819. BEGIN
  820.  
  821.   Deg := RadToDeg( 0.0    );  { Deg =   0.0000 }
  822.   Deg := RadToDeg( PI/6.0 );  { Deg =  30.0000 }
  823.   Deg := RadToDeg( PI*0.25);  { Deg =  45.0000 }
  824.   Deg := RadToDeg( PI*0.5 );  { Deg =  90.0000 }
  825.   Deg := RadToDeg( PI     );  { Deg = 180.0000 }
  826.   Deg := RadToDeg( PI*2.0 );  { Deg = 360.0000 }
  827.  
  828. END;
  829.  
  830.  
  831. ──────────────────────────────────────────────────────────────────────────────
  832.  
  833.  
  834. [FUNCTION]
  835.  
  836. Function RadToGrad(          Rad       : REAL         ) : REAL;
  837.  
  838. [PARAMETERS]
  839.  
  840. Rad         Angle in Radians
  841.  
  842. [RETURNS]
  843.  
  844. Angle in Gradients
  845.  
  846. [DESCRIPTION]
  847.  
  848. Converts Arc Radians to Gradients
  849.  
  850. [SEE-ALSO]
  851.  
  852. DegToRad
  853. DegToGrad
  854. RadToDeg
  855. GradToDeg
  856. GradToRad
  857.  
  858. [EXAMPLE]
  859.  
  860. VAR
  861.   Grad : REAL;
  862.  
  863. BEGIN
  864.  
  865.   Grad := RadToGrad( 0.0    );  { Grad =   0.0000 }
  866.   Grad := RadToGrad( PI/6.0 );  { Grad =  33.3333 }
  867.   Grad := RadToGrad( PI*0.25);  { Grad =  50.0000 }
  868.   Grad := RadToGrad( PI*0.5 );  { Grad = 100.0000 }
  869.   Grad := RadToGrad( PI     );  { Grad = 200.0000 }
  870.   Grad := RadToGrad( 2.0*PI );  { Grad = 400.0000 }
  871.  
  872. END;
  873.  
  874.  
  875. ──────────────────────────────────────────────────────────────────────────────
  876.  
  877.  
  878. [FUNCTION]
  879.  
  880. Function GradToDeg(          Grad      : REAL         ) : REAL;
  881.  
  882. [PARAMETERS]
  883.  
  884. Grad        Angle in Gradients
  885.  
  886. [RETURNS]
  887.  
  888. Arc Degrees
  889.  
  890. [DESCRIPTION]
  891.  
  892. Converts Arc Gradients to Degrees
  893.  
  894. [SEE-ALSO]
  895.  
  896. DegToRad
  897. DegToGrad
  898. RadToDeg
  899. RadToGrad
  900. GradToRad
  901.  
  902. [EXAMPLE]
  903.  
  904. VAR
  905.   Deg : REAL;
  906.  
  907. BEGIN
  908.  
  909.   Deg := GradToDeg(   0.0 );  { Deg =   0.0000 }
  910.   Deg := GradToDeg(  30.0d);  { Deg =  30.0000 }
  911.   Deg := GradToDeg(  50.0 );  { Deg =  45.0000 }
  912.   Deg := GradToDeg( 100.0 );  { Deg =  90.0000 }
  913.   Deg := GradToDeg( 200.0 );  { Deg = 180.0000 }
  914.   Deg := GradToDeg( 400.0 );  { Deg = 360.0000 }
  915.  
  916. END;
  917.  
  918.  
  919. ──────────────────────────────────────────────────────────────────────────────
  920.  
  921.  
  922. [FUNCTION]
  923.  
  924. Function GradToRad(          Grad      : REAL         ) : REAL;
  925.  
  926. [PARAMETERS]
  927.  
  928. Grad        Angle in Gradients
  929.  
  930. [RETURNS]
  931.  
  932. Angle in Radians
  933.  
  934. [DESCRIPTION]
  935.  
  936. Converts Arc Gradients to Radians
  937.  
  938. [SEE-ALSO]
  939.  
  940. DegToRad
  941. DegToGrad
  942. RadToDeg
  943. RadToGrad
  944. GradToDeg
  945.  
  946. [EXAMPLE]
  947.  
  948. VAR
  949.   Rad : REAL;
  950.  
  951. BEGIN
  952.  
  953.   Rad := GradToRad(   0.0000 );  { Rad = 0.0000 }
  954.   Rad := GradToRad(  33.3333 );  { Rad = 0.5236 }
  955.   Rad := GradToRad(  50.0000 );  { Rad = 0.7854 }
  956.   Rad := GradToRad( 100.0000 );  { Rad = 1.5708 }
  957.   Rad := GradToRad( 200.0000 );  { Rad = 3.1416 }
  958.   Rad := GradToRad( 400.0000 );  { Rad = 6.2832 }
  959.  
  960. END;
  961.  
  962.  
  963. ──────────────────────────────────────────────────────────────────────────────
  964.  
  965.  
  966. [FUNCTION]
  967.  
  968. Function Quad(               Radians   : REAL         ) : INTEGER;
  969.  
  970. [PARAMETERS]
  971.  
  972. Radians     Angle in Radians
  973.  
  974. [RETURNS]
  975.  
  976. Quadrant in which the Radians is contained
  977.  
  978. [DESCRIPTION]
  979.  
  980. Determines which Quadrant is the Radian Angle falls in
  981. There are 4 Quadrants as follows:
  982.   Quadrant I   -   0 deg to  90 deg
  983.   Quadrant II  -  91 deg to 180 deg
  984.   Quadrant III - 181 deg to 270 deg
  985.   Quadrant IV  - 271 deg to 359 deg
  986.  
  987. [SEE-ALSO]
  988.  
  989. Quad2
  990.  
  991. [EXAMPLE]
  992.  
  993. VAR
  994.   Q : INTEGER;
  995.  
  996. BEGIN
  997.  
  998.   Q := Quad( DegToRad(   0.0 ) );  { Q = 1 }
  999.   Q := Quad( DegToRad(  45.0 ) );  { Q = 1 }
  1000.   Q := Quad( DegToRad(  90.0 ) );  { Q = 1 }
  1001.   Q := Quad( DegToRad( 135.0 ) );  { Q = 2 }
  1002.   Q := Quad( DegToRad( 210.0 ) );  { Q = 3 }
  1003.   Q := Quad( DegToRad( 300.0 ) );  { Q = 4 }
  1004.  
  1005. END;
  1006.  
  1007.  
  1008. ──────────────────────────────────────────────────────────────────────────────
  1009.  
  1010.  
  1011. [FUNCTION]
  1012.  
  1013. Function Quad2(              X, Y      : REAL         ) : INTEGER;
  1014.  
  1015. [PARAMETERS]
  1016.  
  1017. X           X Coordinate Value
  1018. Y           Y Coordinate Value
  1019.  
  1020. [RETURNS]
  1021.  
  1022. Returns the Quadrant corresponding to the X and Y Values.
  1023.  
  1024. [DESCRIPTION]
  1025.  
  1026. Determines which Quadrant corresponds to the Coordinate X,Y
  1027.  
  1028. [SEE-ALSO]
  1029.  
  1030. Quad
  1031.  
  1032. [EXAMPLE]
  1033.  
  1034. VAR
  1035.   Q : INTEGER;
  1036.  
  1037. BEGIN
  1038.  
  1039.   Q := Quad2(  1.0,  0.0 );  { Q = 1 }
  1040.   Q := Quad2(  1.0,  1.0 );  { Q = 1 }
  1041.   Q := Quad2(  0.0,  1.0 );  { Q = 1 }
  1042.   Q := Quad2( -1.0,  1.0 );  { Q = 2 }
  1043.   Q := Quad2( -1.0, -1.0 );  { Q = 3 }
  1044.   Q := Quad2(  1.0, -1.0 );  { Q = 4 }
  1045.  
  1046. END;
  1047.  
  1048.  
  1049. ──────────────────────────────────────────────────────────────────────────────
  1050.  
  1051.  
  1052. [FUNCTION]
  1053.  
  1054. Function Sin2(               X,Y       : REAL         ) : REAL;
  1055.  
  1056. [PARAMETERS]
  1057.  
  1058. X           X Coordinate Value
  1059. Y           Y Coordinate Value
  1060.  
  1061. [RETURNS]
  1062.  
  1063. Sine of the Angle created by Coordinate X,Y
  1064.  
  1065. [DESCRIPTION]
  1066.  
  1067. Determines and returns the Sine of the Angle computed from
  1068. the Coordinate X,Y
  1069.  
  1070. [SEE-ALSO]
  1071.  
  1072. Cos2   Sinh   ArcSin    ArcSinh
  1073. Tan    Cosh   ArcSin2   ArcCosh
  1074. Tan2   Tanh   ArcCos    ArcTanh
  1075. Cot           ArcCos2   ArcCsch
  1076. Cot2          ArcTan1   ArcSech
  1077. Csc           ArcTan2   ArcCoth
  1078. Sec           ArcCsc
  1079.               ArcSec
  1080.               ArcCot
  1081.  
  1082. [EXAMPLE]
  1083.  
  1084. VAR
  1085.   I : INTEGER;
  1086.  
  1087. BEGIN
  1088.  
  1089.   For i := 0 to 100 Do
  1090.     WriteLn( 'Sin2(1,',i,') = ',Sin2( 1.0, i ) :8:4 );
  1091.  
  1092. END;
  1093.  
  1094.  
  1095. ──────────────────────────────────────────────────────────────────────────────
  1096.  
  1097.  
  1098. [FUNCTION]
  1099.  
  1100. Function Cos2(               X,Y       : REAL         ) : REAL;
  1101.  
  1102. [PARAMETERS]
  1103.  
  1104. X           X Coordinate Value
  1105. Y           Y Coordinate Value
  1106.  
  1107. [RETURNS]
  1108.  
  1109. CoSine of Angle created by Coordinate X,Y
  1110.  
  1111. [DESCRIPTION]
  1112.  
  1113. Determines and returns the CoSine of the Angle computed from
  1114. the Coordinate X,Y
  1115.  
  1116. [SEE-ALSO]
  1117.  
  1118. Sin2   Sinh   ArcSin    ArcSinh
  1119. Tan    Cosh   ArcSin2   ArcCosh
  1120. Tan2   Tanh   ArcCos    ArcTanh
  1121. Cot           ArcCos2   ArcCsch
  1122. Cot2          ArcTan1   ArcSech
  1123. Csc           ArcTan2   ArcCoth
  1124. Sec           ArcCsc
  1125.               ArcSec
  1126.               ArcCot
  1127.  
  1128. [EXAMPLE]
  1129.  
  1130. VAR
  1131.   I : INTEGER;
  1132.  
  1133. BEGIN
  1134.  
  1135.   For i := 0 to 100 Do
  1136.     WriteLn( 'Cos2(1,',i,') = ',Cos2( 1.0, i ) :8:4 );
  1137.  
  1138. END;
  1139.  
  1140.  
  1141. ──────────────────────────────────────────────────────────────────────────────
  1142.  
  1143.  
  1144. [FUNCTION]
  1145.  
  1146. Function Tan(                X         : REAL         ) : REAL;
  1147.  
  1148. [PARAMETERS]
  1149.  
  1150. X           Angle in Radians
  1151.  
  1152. [RETURNS]
  1153.  
  1154. Returns the Tangent of the Angle
  1155.  
  1156. [DESCRIPTION]
  1157.  
  1158. Computes and returns the Tangent of the given Angle.  Replaces
  1159. Std Pascal "Tan" as handles range checking and bounds.
  1160.  
  1161. [SEE-ALSO]
  1162.  
  1163. Sin2   Sinh   ArcSin    ArcSinh
  1164. Cos2   Cosh   ArcSin2   ArcCosh
  1165. Tan2   Tanh   ArcCos    ArcTanh
  1166. Cot           ArcCos2   ArcCsch
  1167. Cot2          ArcTan1   ArcSech
  1168. Csc           ArcTan2   ArcCoth
  1169. Sec           ArcCsc
  1170.               ArcSec
  1171.               ArcCot
  1172.  
  1173. [EXAMPLE]
  1174.  
  1175. VAR
  1176.   R : REAL;
  1177.   I : INTEGER;
  1178.  
  1179. BEGIN
  1180.  
  1181.   R := 0.0;
  1182.   For i := 0 to 100 Do
  1183.   BEGIN
  1184.  
  1185.     WriteLn( 'Tan(',R:0:0,') = ',Tan( R ) :8:4 );
  1186.     R := R + 1.0;
  1187.  
  1188.   END;  { For i }
  1189.  
  1190. END;
  1191.  
  1192.  
  1193. ──────────────────────────────────────────────────────────────────────────────
  1194.  
  1195.  
  1196. [FUNCTION]
  1197.  
  1198. Function Tan2(               X, Y      : REAL         ) : REAL;
  1199.  
  1200. [PARAMETERS]
  1201.  
  1202. X           X Coordinate Value
  1203. Y           Y Coordinate Value
  1204.  
  1205. [RETURNS]
  1206.  
  1207. Tangent of the Angle created by Coordinate X,Y
  1208.  
  1209. [DESCRIPTION]
  1210.  
  1211. Computes and returns the Tangent of the Angle computed from
  1212. the Coordinate X,Y
  1213.  
  1214. [SEE-ALSO]
  1215.  
  1216. Sin2   Sinh   ArcSin    ArcSinh
  1217. Cos2   Cosh   ArcSin2   ArcCosh
  1218. Tan    Tanh   ArcCos    ArcTanh
  1219. Cot           ArcCos2   ArcCsch
  1220. Cot2          ArcTan1   ArcSech
  1221. Csc           ArcTan2   ArcCoth
  1222. Sec           ArcCsc
  1223.               ArcSec
  1224.               ArcCot
  1225.  
  1226. [EXAMPLE]
  1227.  
  1228. VAR
  1229.   I : INTEGER;
  1230.  
  1231. BEGIN
  1232.  
  1233.   For i := 0 to 100 Do
  1234.     WriteLn( 'Tan2(1,',i,') = ',Tan2( 1.0, i ) :8:4 );
  1235.  
  1236. END;
  1237.  
  1238.  
  1239. ──────────────────────────────────────────────────────────────────────────────
  1240.  
  1241.  
  1242. [FUNCTION]
  1243.  
  1244. Function Cot(                X         : REAL         ) : REAL;
  1245.  
  1246. [PARAMETERS]
  1247.  
  1248. X           Angle in Radians
  1249.  
  1250. [RETURNS]
  1251.  
  1252. CoTangent of the Angle
  1253.  
  1254. [DESCRIPTION]
  1255.  
  1256. Conputes and returns the CoTangent of a given Angle.
  1257.  
  1258. [SEE-ALSO]
  1259.  
  1260. Sin2   Sinh   ArcSin    ArcSinh
  1261. Cos2   Cosh   ArcSin2   ArcCosh
  1262. Tan    Tanh   ArcCos    ArcTanh
  1263. Tan2          ArcCos2   ArcCsch
  1264. Cot2          ArcTan1   ArcSech
  1265. Csc           ArcTan2   ArcCoth
  1266. Sec           ArcCsc
  1267.               ArcSec
  1268.               ArcCot
  1269.  
  1270. [EXAMPLE]
  1271.  
  1272. VAR
  1273.   I : INTEGER;
  1274.   R : REAL;
  1275.  
  1276. BEGIN
  1277.  
  1278.   R := 0.0;
  1279.   For i := 0 to 100 Do
  1280.   BEGIN
  1281.  
  1282.     WriteLn( 'Cot(',R:0:0,') = ',Cot( 1.0, i ) :8:4 );
  1283.     R := R + 1.0;
  1284.  
  1285.   END;  { For i }
  1286.  
  1287. END;
  1288.  
  1289.  
  1290. ──────────────────────────────────────────────────────────────────────────────
  1291.  
  1292.  
  1293. [FUNCTION]
  1294.  
  1295. Function Cot2(               X, Y      : REAL         ) : REAL;
  1296.  
  1297. [PARAMETERS]
  1298.  
  1299. X           X Coordinate Value
  1300. Y           Y Coordinate Value
  1301.  
  1302. [RETURNS]
  1303.  
  1304. CoTangent of Angle computed from Coordinate X,Y
  1305.  
  1306. [DESCRIPTION]
  1307.  
  1308. Computes and returns the CoTangent of an Angle computed from
  1309. the  Coordinate X,Y
  1310.  
  1311. [SEE-ALSO]
  1312.  
  1313. Sin2   Sinh   ArcSin    ArcSinh
  1314. Cos2   Cosh   ArcSin2   ArcCosh
  1315. Tan    Tanh   ArcCos    ArcTanh
  1316. Tan2          ArcCos2   ArcCsch
  1317. Cot           ArcTan1   ArcSech
  1318. Csc           ArcTan2   ArcCoth
  1319. Sec           ArcCsc
  1320.               ArcSec
  1321.               ArcCot
  1322.  
  1323. [EXAMPLE]
  1324.  
  1325. VAR
  1326.   I : INTEGER;
  1327.  
  1328. BEGIN
  1329.  
  1330.   For i := 0 to 100 Do
  1331.     WriteLn( 'Cot2(1,',i,') = ',Cot2( 1.0, i ) :8:4 );
  1332.  
  1333. END;
  1334.  
  1335.  
  1336. ──────────────────────────────────────────────────────────────────────────────
  1337.  
  1338.  
  1339. [FUNCTION]
  1340.  
  1341. Function Csc(                X         : REAL         ) : REAL;
  1342.  
  1343. [PARAMETERS]
  1344.  
  1345. X           Angle in Radians
  1346.  
  1347. [RETURNS]
  1348.  
  1349. CoSecant of Angle
  1350.  
  1351. [DESCRIPTION]
  1352.  
  1353. Computes and returns the CoSecant of a given Angle
  1354.  
  1355. [SEE-ALSO]
  1356.  
  1357. Sin2   Sinh   ArcSin    ArcSinh
  1358. Cos2   Cosh   ArcSin2   ArcCosh
  1359. Tan    Tanh   ArcCos    ArcTanh
  1360. Tan2          ArcCos2   ArcCsch
  1361. Cot           ArcTan1   ArcSech
  1362. Cot2          ArcTan2   ArcCoth
  1363. Sec           ArcCsc
  1364.               ArcSec
  1365.               ArcCot
  1366.  
  1367. [EXAMPLE]
  1368.  
  1369. VAR
  1370.   I : INTEGER;
  1371.   R : REAL;
  1372.  
  1373. BEGIN
  1374.  
  1375.   R := 0.0;
  1376.   For i := 0 to 100 Do
  1377.   BEGIN
  1378.  
  1379.     WriteLn( 'Csc(',R:0:0,') = ',Csc( R ) :8:4 );
  1380.     R := R + 1.0;
  1381.  
  1382.   END;  { For i }
  1383.  
  1384. END;
  1385.  
  1386.  
  1387. ──────────────────────────────────────────────────────────────────────────────
  1388.  
  1389.  
  1390. [FUNCTION]
  1391.  
  1392. Function Sec(                X         : REAL         ) : REAL;
  1393.  
  1394. [PARAMETERS]
  1395.  
  1396. X           Angle in Radians
  1397.  
  1398. [RETURNS]
  1399.  
  1400. Secant of Angle
  1401.  
  1402. [DESCRIPTION]
  1403.  
  1404. Computes and returns the Secant of a given Angle
  1405.  
  1406. [SEE-ALSO]
  1407.  
  1408. Sin2   Sinh   ArcSin    ArcSinh
  1409. Cos2   Cosh   ArcSin2   ArcCosh
  1410. Tan    Tanh   ArcCos    ArcTanh
  1411. Tan2          ArcCos2   ArcCsch
  1412. Cot           ArcTan1   ArcSech
  1413. Cot2          ArcTan2   ArcCoth
  1414. Csc           ArcCsc
  1415.               ArcSec
  1416.               ArcCot
  1417.  
  1418. [EXAMPLE]
  1419.  
  1420.  
  1421. VAR
  1422.   I : INTEGER;
  1423.   R : REAL;
  1424.  
  1425. BEGIN
  1426.  
  1427.   R := 0.0;
  1428.   For i := 0 to 100 Do
  1429.   BEGIN
  1430.  
  1431.     WriteLn( 'Sec(',R:0:0,') = ',Sec( R ) :8:4 );
  1432.     R := R + 1.0;
  1433.  
  1434.   END;  { For i }
  1435.  
  1436. END;
  1437.  
  1438.  
  1439. ──────────────────────────────────────────────────────────────────────────────
  1440.  
  1441.  
  1442. [FUNCTION]
  1443.  
  1444. Function Sinh(               X         : REAL         ) : REAL;  {NOT TESTED}
  1445.  
  1446. [PARAMETERS]
  1447.  
  1448. X           Angle in Radians
  1449.  
  1450. [RETURNS]
  1451.  
  1452. Hyperbolic Sine of Angle
  1453.  
  1454. [DESCRIPTION]
  1455.  
  1456. Computes and returns the Hyperbolic Sine of a given Angle
  1457.  
  1458. [SEE-ALSO]
  1459.  
  1460. Sin2   Cosh   ArcSin    ArcSinh
  1461. Cos2   Tanh   ArcSin2   ArcCosh
  1462. Tan           ArcCos    ArcTanh
  1463. Tan2          ArcCos2   ArcCsch
  1464. Cot           ArcTan1   ArcSech
  1465. Cot2          ArcTan2   ArcCoth
  1466. Csc           ArcCsc
  1467. Sec           ArcSec
  1468.               ArcCot
  1469.  
  1470. [EXAMPLE]
  1471.  
  1472. VAR
  1473.   I : INTEGER;
  1474.   R : REAL;
  1475.  
  1476. BEGIN
  1477.  
  1478.   R := 0.0;
  1479.   For i := 0 to 100 Do
  1480.   BEGIN
  1481.  
  1482.     WriteLn( 'Sinh(',R:0:0,') = ',Sinh( R ) :8:4 );
  1483.     R := R + 1.0;
  1484.  
  1485.   END;  { For i }
  1486.  
  1487. END;
  1488.  
  1489.  
  1490. ──────────────────────────────────────────────────────────────────────────────
  1491.  
  1492.  
  1493. [FUNCTION]
  1494.  
  1495. Function Cosh(               X         : REAL         ) : REAL;
  1496.  
  1497. [PARAMETERS]
  1498.  
  1499. X           Angle in Radians
  1500.  
  1501. [RETURNS]
  1502.  
  1503. Hyperbolic CoSine of Angle
  1504.  
  1505. [DESCRIPTION]
  1506.  
  1507. Computes and returns the Hyperbolic CoSine of a given Angle
  1508.  
  1509. [SEE-ALSO]
  1510.  
  1511. Sin2   Sinh   ArcSin    ArcSinh
  1512. Cos2   Tanh   ArcSin2   ArcCosh
  1513. Tan           ArcCos    ArcTanh
  1514. Tan2          ArcCos2   ArcCsch
  1515. Cot           ArcTan1   ArcSech
  1516. Cot2          ArcTan2   ArcCoth
  1517. Csc           ArcCsc
  1518. Sec           ArcSec
  1519.               ArcCot
  1520.  
  1521. [EXAMPLE]
  1522.  
  1523. VAR
  1524.   I : INTEGER;
  1525.   R : REAL;
  1526.  
  1527. BEGIN
  1528.  
  1529.   R := 0.0;
  1530.   For i := 0 to 100 Do
  1531.   BEGIN
  1532.  
  1533.     WriteLn( 'Cosh(',R:0:0,') = ',Cosh( R ) :8:4 );
  1534.     R := R + 1.0;
  1535.  
  1536.   END;  { For i }
  1537.  
  1538. END;
  1539.  
  1540.  
  1541. ──────────────────────────────────────────────────────────────────────────────
  1542.  
  1543.  
  1544. [FUNCTION]
  1545.  
  1546. Function Tanh(               X         : REAL         ) : REAL;
  1547.  
  1548. [PARAMETERS]
  1549.  
  1550. X           Angle in Radians
  1551.  
  1552. [RETURNS]
  1553.  
  1554. Hyperbolic Tangent of Angle
  1555.  
  1556. [DESCRIPTION]
  1557.  
  1558. Computes and returns the Hyperbolic Tangent of a given Angle
  1559.  
  1560. [SEE-ALSO]
  1561.  
  1562. Sin2   Sinh   ArcSin    ArcSinh
  1563. Cos2   Cosh   ArcSin2   ArcCosh
  1564. Tan           ArcCos    ArcTanh
  1565. Tan2          ArcCos2   ArcCsch
  1566. Cot           ArcTan1   ArcSech
  1567. Cot2          ArcTan2   ArcCoth
  1568. Csc           ArcCsc
  1569. Sec           ArcSec
  1570.               ArcCot
  1571.  
  1572. [EXAMPLE]
  1573.  
  1574. VAR
  1575.   I : INTEGER;
  1576.   R : REAL;
  1577.  
  1578. BEGIN
  1579.  
  1580.   R := 0.0;
  1581.   For i := 0 to 100 Do
  1582.   BEGIN
  1583.  
  1584.     WriteLn( 'Tanh(',R:0:0,') = ',Tanh( R ) :8:4 );
  1585.     R := R + 1.0;
  1586.  
  1587.   END;  { For i }
  1588.  
  1589. END;
  1590.  
  1591.  
  1592. ──────────────────────────────────────────────────────────────────────────────
  1593.  
  1594.  
  1595. [FUNCTION]
  1596.  
  1597. Function Csch(               X         : REAL         ) : REAL;  {NOT TESTED}
  1598.  
  1599. [PARAMETERS]
  1600.  
  1601. X           Angle in Radians
  1602.  
  1603. [RETURNS]
  1604.  
  1605. Hyperbolic Cosecant of Angle
  1606.  
  1607. [DESCRIPTION]
  1608.  
  1609. Computes and returns the Hyperbolic Cosecant of a given Angle
  1610.  
  1611. [SEE-ALSO]
  1612.  
  1613. Sin2   Cosh   ArcSin    ArcSinh
  1614. Cos2   Tanh   ArcSin2   ArcCosh
  1615. Tan           ArcCos    ArcTanh
  1616. Tan2          ArcCos2   ArcCsch
  1617. Cot           ArcTan1   ArcSech
  1618. Cot2          ArcTan2   ArcCoth
  1619. Csc           ArcCsc
  1620. Sec           ArcSec
  1621.               ArcCot
  1622.  
  1623. [EXAMPLE]
  1624.  
  1625. VAR
  1626.   I : INTEGER;
  1627.   R : REAL;
  1628.  
  1629. BEGIN
  1630.  
  1631.   R := 0.0;
  1632.   For i := 0 to 100 Do
  1633.   BEGIN
  1634.  
  1635.     WriteLn( 'Csch(',R:0:0,') = ',Csch( R ) :8:4 );
  1636.     R := R + 1.0;
  1637.  
  1638.   END;  { For i }
  1639.  
  1640. END;
  1641.  
  1642.  
  1643. ──────────────────────────────────────────────────────────────────────────────
  1644.  
  1645.  
  1646. [FUNCTION]
  1647.  
  1648. Function Sech(                X         : REAL         ) : REAL;
  1649.  
  1650. [PARAMETERS]
  1651.  
  1652. X           Angle in Radians
  1653.  
  1654. [RETURNS]
  1655.  
  1656. Hyperbolic Secant of Angle
  1657.  
  1658. [DESCRIPTION]
  1659.  
  1660. Computes and returns the Hyperbolic Secant of a given Angle
  1661.  
  1662. [SEE-ALSO]
  1663.  
  1664. Sin2   Sinh   ArcSin    ArcSinh
  1665. Cos2   Tanh   ArcSin2   ArcCosh
  1666. Tan           ArcCos    ArcTanh
  1667. Tan2          ArcCos2   ArcCsch
  1668. Cot           ArcTan1   ArcSech
  1669. Cot2          ArcTan2   ArcCoth
  1670. Csc           ArcCsc
  1671. Sec           ArcSec
  1672.               ArcCot
  1673.  
  1674. [EXAMPLE]
  1675.  
  1676. VAR
  1677.   I : INTEGER;
  1678.   R : REAL;
  1679.  
  1680. BEGIN
  1681.  
  1682.   R := 0.0;
  1683.   For i := 0 to 100 Do
  1684.   BEGIN
  1685.  
  1686.     WriteLn( 'Sech(',R:0:0,') = ',Sech( R ) :8:4 );
  1687.     R := R + 1.0;
  1688.  
  1689.   END;  { For i }
  1690.  
  1691. END;
  1692.  
  1693.  
  1694. ──────────────────────────────────────────────────────────────────────────────
  1695.  
  1696.  
  1697. [FUNCTION]
  1698.  
  1699. Function Coth(               X         : REAL         ) : REAL;
  1700.  
  1701. [PARAMETERS]
  1702.  
  1703. X           Angle in Radians
  1704.  
  1705. [RETURNS]
  1706.  
  1707. Hyperbolic Cotangent of Angle
  1708.  
  1709. [DESCRIPTION]
  1710.  
  1711. Computes and returns the Hyperbolic Cotangent of a given Angle
  1712.  
  1713. [SEE-ALSO]
  1714.  
  1715. Sin2   Sinh   ArcSin    ArcSinh
  1716. Cos2   Cosh   ArcSin2   ArcCosh
  1717. Tan           ArcCos    ArcTanh
  1718. Tan2          ArcCos2   ArcCsch
  1719. Cot           ArcTan1   ArcSech
  1720. Cot2          ArcTan2   ArcCoth
  1721. Csc           ArcCsc
  1722. Sec           ArcSec
  1723.               ArcCot
  1724.  
  1725. [EXAMPLE]
  1726.  
  1727. VAR
  1728.   I : INTEGER;
  1729.   R : REAL;
  1730.  
  1731. BEGIN
  1732.  
  1733.   R := 0.0;
  1734.   For i := 0 to 100 Do
  1735.   BEGIN
  1736.  
  1737.     WriteLn( 'Coth(',R:0:0,') = ',Coth( R ) :8:4 );
  1738.     R := R + 1.0;
  1739.  
  1740.   END;  { For i }
  1741.  
  1742. END;
  1743.  
  1744.  
  1745. ──────────────────────────────────────────────────────────────────────────────
  1746.  
  1747.  
  1748. [FUNCTION]
  1749.  
  1750. Function ArcSin(             X     : REAL         ) : REAL;
  1751.  
  1752. [PARAMETERS]
  1753.  
  1754. X       Sine Value
  1755.  
  1756. [RETURNS]
  1757.  
  1758. Angle in radians whose sine is X.
  1759.  
  1760. [DESCRIPTION]
  1761.  
  1762. Computes and returns the Inverse sine of a given value.
  1763. Positive sine values are assumed quadrant 1 and negative sine
  1764. values are assumed as quadrant 4 as there is no means to
  1765. compute an absolute angle based on the simple sine value.
  1766.  
  1767. NOTE: Sine Value is NOT Range Checked and MUST be in Bounds.
  1768.  
  1769. [SEE-ALSO]
  1770.  
  1771. Sin2   Sinh   ArcSin2   ArcSinh
  1772. Cos2   Cosh   ArcCos    ArcCosh
  1773. Tan    Tanh   ArcCos2   ArcTanh
  1774. Tan2          ArcTan1   ArcCsch
  1775. Cot           ArcTan2   ArcSech
  1776. Cot2          ArcCsc    ArcCoth
  1777. Csc           ArcSec
  1778. Sec           ArcCot
  1779.  
  1780. [EXAMPLE]
  1781.  
  1782. VAR
  1783.   I : INTEGER;
  1784.   R : REAL;
  1785.  
  1786. BEGIN
  1787.  
  1788.   R := 1.0;
  1789.   For i := 100 DownTo 0 Do
  1790.   BEGIN
  1791.  
  1792.     WriteLn( 'ArcSin(',R:0:0,') = ',ArcSin( R ) :8:4 );
  1793.     R := R - 0.01;
  1794.  
  1795.   END;  { For i }
  1796.  
  1797. END;
  1798.  
  1799.  
  1800. ──────────────────────────────────────────────────────────────────────────────
  1801.  
  1802.  
  1803. [FUNCTION]
  1804.  
  1805. Function ArcSin2(            X     : REAL;
  1806.                              Quadrant  : INTEGER      ) : REAL;
  1807.  
  1808. [PARAMETERS]
  1809.  
  1810. X       Sine Value
  1811. Quadrant    Angular Quadrant Containing Sine Value
  1812.  
  1813. [RETURNS]
  1814.  
  1815. Arc Sine Angle of Sine X in Radians.
  1816.  
  1817. [DESCRIPTION]
  1818.  
  1819. Computes and returns the Arc Sine of a given Sine Value.
  1820. Using the input Quadrant, the Correct Absolute Sine Angle
  1821. is determined.
  1822.  
  1823. NOTE: Sine Value is NOT Range Checked and MUST be in Bounds.
  1824.  
  1825. [SEE-ALSO]
  1826.  
  1827. Sin2   Sinh   ArcSin    ArcSinh
  1828. Cos2   Cosh   ArcCos    ArcCosh
  1829. Tan    Tanh   ArcCos2   ArcTanh
  1830. Tan2          ArcTan1   ArcCsch
  1831. Cot           ArcTan2   ArcSech
  1832. Cot2          ArcCsc    ArcCoth
  1833. Csc           ArcSec
  1834. Sec           ArcCot
  1835.  
  1836. [EXAMPLE]
  1837.  
  1838. VAR
  1839.   I : INTEGER;
  1840.   R : REAL;
  1841.  
  1842. BEGIN
  1843.  
  1844.   R := 1.0;
  1845.   For i := 100 DownTo 0 Do
  1846.   BEGIN
  1847.  
  1848.     WriteLn( 'ArcSin2(',R:0:0,') [Quad=3] = ',ArcSin2( R, 3 ) :8:4 );
  1849.     R := R - 0.01;
  1850.  
  1851.   END;  { For i }
  1852.  
  1853. END;
  1854.  
  1855.  
  1856. ──────────────────────────────────────────────────────────────────────────────
  1857.  
  1858.  
  1859. [FUNCTION]
  1860.  
  1861. Function ArcCos(             X     : REAL         ) : REAL;
  1862.  
  1863. [PARAMETERS]
  1864.  
  1865. X       CoSine Value
  1866.  
  1867. [RETURNS]
  1868.  
  1869. Inverse cosine angle in radians.
  1870.  
  1871. [DESCRIPTION]
  1872.  
  1873. Computes and returns the Arc CoSine of a given CoSine Value.
  1874. Positive CoSine Values are assumed Quadrant 1 and negative
  1875. CoSine Values are assumed Quadrant 2 as there is no means to
  1876. compute Absolute Angle based upon Simple CoSine Value.
  1877.  
  1878. [SEE-ALSO]
  1879.  
  1880. Sin2   Sinh   ArcSin    ArcSinh
  1881. Cos2   Cosh   ArcSin2   ArcCosh
  1882. Tan    Tanh   ArcCos2   ArcTanh
  1883. Tan2          ArcTan1   ArcCsch
  1884. Cot           ArcTan2   ArcSech
  1885. Cot2          ArcCsc    ArcCoth
  1886. Csc           ArcSec
  1887. Sec           ArcCot
  1888.  
  1889. [EXAMPLE]
  1890.  
  1891. VAR
  1892.   I : INTEGER;
  1893.   R : REAL;
  1894.  
  1895. BEGIN
  1896.  
  1897.   R := 1.0;
  1898.   For i := 100 DownTo 0 Do
  1899.   BEGIN
  1900.  
  1901.     WriteLn( 'ArcCos(',R:0:0,') = ',ArcCos( R ) :8:4 );
  1902.     R := R - 0.01;
  1903.  
  1904.   END;  { For i }
  1905.  
  1906. END;
  1907.  
  1908.  
  1909. ──────────────────────────────────────────────────────────────────────────────
  1910.  
  1911.  
  1912. [FUNCTION]
  1913.  
  1914. Function ArcCos2(            X     : REAL;
  1915.                              Quadrant  : INTEGER      ) : REAL;
  1916.  
  1917. [PARAMETERS]
  1918.  
  1919. X       CoSine Value
  1920. Quadrant    Angular Quadrant Containing CoSine Value
  1921.  
  1922. [RETURNS]
  1923.  
  1924. Arc CoSine Angle of CoSine Value
  1925.  
  1926. [DESCRIPTION]
  1927.  
  1928. Computes and returns the Arc CoSine of a given CoSine Value.
  1929. Using the input Quadrant, the Correct Absolute CoSine Angle
  1930. is determined.
  1931.  
  1932. NOTE: Cosine Value is NOT Range Checked and MUST be in Bounds.
  1933.  
  1934. [SEE-ALSO]
  1935.  
  1936. Sin2   Sinh   ArcSin    ArcSinh
  1937. Cos2   Cosh   ArcSin2   ArcCosh
  1938. Tan    Tanh   ArcCos    ArcTanh
  1939. Tan2          ArcTan1   ArcCsch
  1940. Cot           ArcTan2   ArcSech
  1941. Cot2          ArcCsc    ArcCoth
  1942. Csc           ArcSec
  1943. Sec           ArcCot
  1944.  
  1945. [EXAMPLE]
  1946.  
  1947. VAR
  1948.   I : INTEGER;
  1949.   R : REAL;
  1950.  
  1951. BEGIN
  1952.  
  1953.   R := 1.0;
  1954.   For i := 100 DownTo 0 Do
  1955.   BEGIN
  1956.  
  1957.     WriteLn( 'ArcCos2(',R:0:0,') [Quad=3] = ',ArcCos2( R,3 ) :8:4 );
  1958.     R := R - 0.01;
  1959.  
  1960.   END;  { For i }
  1961.  
  1962. END;
  1963.  
  1964.  
  1965. ──────────────────────────────────────────────────────────────────────────────
  1966.  
  1967.  
  1968. [FUNCTION]
  1969.  
  1970. Function ArcTan1(            X     : REAL         ) : REAL;
  1971.  
  1972. [PARAMETERS]
  1973.  
  1974. X       Tangent Value
  1975.  
  1976. [RETURNS]
  1977.  
  1978. Arc Tangent Angle of Tangent X
  1979.  
  1980. [DESCRIPTION]
  1981.  
  1982. Computes and returns the Arc Tangent of a given Tangent Value.
  1983. Positive Tangent Values are assumed Quadrant 1 and negative
  1984. Tangent Values are assumed Quadrant 4 as there is no means to
  1985. compute Absolute Angle based upon Simple Tangent Value.
  1986.  
  1987. NOTE: Limiting Tangent Range is based upon the Constant cINFINITY.
  1988. Anything exceeds this in either direction is considered 90 degrees.
  1989.  
  1990. [SEE-ALSO]
  1991.  
  1992. Sin2   Sinh   ArcSin    ArcSinh
  1993. Cos2   Cosh   ArcSin2   ArcCosh
  1994. Tan    Tanh   ArcCos    ArcTanh
  1995. Tan2          ArcCos2   ArcCsch
  1996. Cot           ArcTan2   ArcSech
  1997. Cot2          ArcCsc    ArcCoth
  1998. Csc           ArcSec
  1999. Sec           ArcCot
  2000.  
  2001. [EXAMPLE]
  2002.  
  2003. VAR
  2004.   I : INTEGER;
  2005.   R : REAL;
  2006.  
  2007. BEGIN
  2008.  
  2009.   R := 1.0;
  2010.   For i := 100 DownTo 0 Do
  2011.   BEGIN
  2012.  
  2013.     WriteLn( 'ArcTan1(',R:0:0,') = ',ArcTan1( R ) :8:4 );
  2014.     R := R - 0.01;
  2015.  
  2016.   END;  { For i }
  2017.  
  2018. END;
  2019.  
  2020.  
  2021. ──────────────────────────────────────────────────────────────────────────────
  2022.  
  2023.  
  2024. [FUNCTION]
  2025.  
  2026. Function ArcTan2(            X, Y      : REAL         ) : REAL;
  2027.  
  2028. [PARAMETERS]
  2029.  
  2030. X           X Coordinate Value
  2031. Y           Y Coordinate Value
  2032.  
  2033. [RETURNS]
  2034.  
  2035. Arc Tangent Angle computed from Coordinate X,Y
  2036.  
  2037. [DESCRIPTION]
  2038.  
  2039. Determines and returns the ArcTangent Angle of a given Tangent
  2040. Value computed from the Coordinate X,Y
  2041.  
  2042.  
  2043. Borland Pascal has a problem with an Angle in the 4th Quadrant
  2044. when the argument becomes negative.  The Negative argument table
  2045. has not been uniformly prepared.  This function handles that
  2046. problem.
  2047.  
  2048. [SEE-ALSO]
  2049.  
  2050. Sin2   Sinh   ArcSin    ArcSinh
  2051. Cos2   Cosh   ArcSin2   ArcCosh
  2052. Tan    Tanh   ArcCos    ArcTanh
  2053. Tan2          ArcCos2   ArcCsch
  2054. Cot           ArcTan1   ArcSech
  2055. Cot2          ArcCsc    ArcCoth
  2056. Csc           ArcSec
  2057. Sec           ArcCot
  2058.  
  2059. [EXAMPLE]
  2060.  
  2061. VAR
  2062.   I : INTEGER;
  2063.  
  2064. BEGIN
  2065.  
  2066.   For i := 100 DownTo 0 Do
  2067.     WriteLn( 'ArcTan2(1,',i,') = ',ArcTan2( 1, i ) :8:4 );
  2068.  
  2069. END;
  2070.  
  2071.  
  2072. ──────────────────────────────────────────────────────────────────────────────
  2073.  
  2074.  
  2075. [FUNCTION]
  2076.  
  2077. Function ArcCsc(             X     : REAL         ) : REAL;
  2078.  
  2079. [PARAMETERS]
  2080.  
  2081. X       CoSecant Value
  2082.  
  2083. [RETURNS]
  2084.  
  2085. Inverse cosecant angle in radians.
  2086.  
  2087. [DESCRIPTION]
  2088.  
  2089. [SEE-ALSO]
  2090.  
  2091. Sin2   Sinh   ArcSin    ArcSinh
  2092. Cos2   Cosh   ArcSin2   ArcCosh
  2093. Tan    Tanh   ArcCos    ArcTanh
  2094. Tan2          ArcCos2   ArcCsch
  2095. Cot           ArcTan1   ArcSech
  2096. Cot2          ArcTan2   ArcCoth
  2097. Csc           ArcSec
  2098. Sec           ArcCot
  2099.  
  2100. [EXAMPLE]
  2101.  
  2102. VAR
  2103.   I : INTEGER;
  2104.   R : REAL;
  2105.  
  2106. BEGIN
  2107.  
  2108.   R := 1.0;
  2109.   For i := 100 DownTo 0 Do
  2110.   BEGIN
  2111.  
  2112.     WriteLn( 'ArcCsc(',R:0:0,') = ',ArcCsc( R ) :8:4 );
  2113.     R := R - 0.01;
  2114.  
  2115.   END;  { For i }
  2116.  
  2117. END;
  2118.  
  2119.  
  2120. ──────────────────────────────────────────────────────────────────────────────
  2121.  
  2122.  
  2123. [FUNCTION]
  2124.  
  2125. Function ArcSec(             X     : REAL         ) : REAL;
  2126.  
  2127. [PARAMETERS]
  2128.  
  2129. X       Secant Value
  2130.  
  2131. [RETURNS]
  2132.  
  2133. Inverse secant angle in radians.
  2134.  
  2135. [DESCRIPTION]
  2136.  
  2137. [SEE-ALSO]
  2138.  
  2139. Sin2   Sinh   ArcSin    ArcSinh
  2140. Cos2   Cosh   ArcSin2   ArcCosh
  2141. Tan    Tanh   ArcCos    ArcTanh
  2142. Tan2          ArcCos2   ArcCsch
  2143. Cot           ArcTan1   ArcSech
  2144. Cot2          ArcTan2   ArcCoth
  2145. Csc           ArcCsc
  2146. Sec           ArcCot
  2147.  
  2148. [EXAMPLE]
  2149.  
  2150. VAR
  2151.   I : INTEGER;
  2152.   R : REAL;
  2153.  
  2154. BEGIN
  2155.  
  2156.   R := 1.0;
  2157.   For i := 100 DownTo 0 Do
  2158.   BEGIN
  2159.  
  2160.     WriteLn( 'ArcSec(',R:0:0,') = ',ArcSec( R ) :8:4 );
  2161.     R := R - 0.01;
  2162.  
  2163.   END;  { For i }
  2164.  
  2165. END;
  2166.  
  2167.  
  2168. ──────────────────────────────────────────────────────────────────────────────
  2169.  
  2170.  
  2171. [FUNCTION]
  2172.  
  2173. Function ArcCot(             X     : REAL         ) : REAL;
  2174.  
  2175. [PARAMETERS]
  2176.  
  2177. X       CoTangent Value
  2178.  
  2179. [RETURNS]
  2180.  
  2181. Inverse cotangent angle in radians.
  2182.  
  2183. [DESCRIPTION]
  2184.  
  2185.  
  2186. [SEE-ALSO]
  2187.  
  2188. Sin2   Sinh   ArcSin    ArcSinh
  2189. Cos2   Cosh   ArcSin2   ArcCosh
  2190. Tan    Tanh   ArcCos    ArcTanh
  2191. Tan2          ArcCos2   ArcCsch
  2192. Cot           ArcTan1   ArcSech
  2193. Cot2          ArcTan2   ArcCoth
  2194. Csc           ArcCsc
  2195. Sec           ArcSec
  2196.  
  2197. [EXAMPLE]
  2198.  
  2199. VAR
  2200.   I : INTEGER;
  2201.   R : REAL;
  2202.  
  2203. BEGIN
  2204.  
  2205.   R := 1.0;
  2206.   For i := 100 DownTo 0 Do
  2207.   BEGIN
  2208.  
  2209.     WriteLn( 'ArcCot(',R:0:0,') = ',ArcCot( R ) :8:4 );
  2210.     R := R - 0.01;
  2211.  
  2212.   END;  { For i }
  2213.  
  2214. END;
  2215.  
  2216.  
  2217. ──────────────────────────────────────────────────────────────────────────────
  2218.  
  2219.  
  2220. [FUNCTION]
  2221.  
  2222. Function ArcSinh(            X     : REAL         ) : REAL;
  2223.  
  2224. [PARAMETERS]
  2225.  
  2226. X       Hyperbolic Sine Value
  2227.  
  2228. [RETURNS]
  2229.  
  2230. Arc Hyperbolic Sine Angle
  2231.  
  2232. [DESCRIPTION]
  2233.  
  2234. Computes and returns the Arc Hyperbolic Sine Angle of a given
  2235. Hyperbolic Sine Angle.
  2236.  
  2237. NOTE: The Hyperbolic Sine Value is NOT Range Checked and MUST
  2238. be in Bounds.
  2239.  
  2240. [SEE-ALSO]
  2241.  
  2242. Sin2   Sinh   ArcSin    ArcCosh
  2243. Cos2   Cosh   ArcSin2   ArcTanh
  2244. Tan    Tanh   ArcCos    ArcCsch
  2245. Tan2          ArcCos2   ArcSech
  2246. Cot           ArcTan1   ArcCoth
  2247. Cot2          ArcTan2
  2248. Csc           ArcCsc
  2249. Sec           ArcSec
  2250.               ArcCot
  2251.  
  2252. [EXAMPLE]
  2253.  
  2254. VAR
  2255.   I : INTEGER;
  2256.   R : REAL;
  2257.  
  2258. BEGIN
  2259.  
  2260.   R := 1.0;
  2261.   For i := 100 DownTo 0 Do
  2262.   BEGIN
  2263.  
  2264.     WriteLn( 'ArcSinh(',R:0:0,') = ',ArcSinh( R ) :8:4 );
  2265.     R := R - 0.01;
  2266.  
  2267.   END;  { For i }
  2268.  
  2269. END;
  2270.  
  2271.  
  2272. ──────────────────────────────────────────────────────────────────────────────
  2273.  
  2274.  
  2275. [FUNCTION]
  2276.  
  2277. Function ArcCosh(            X     : REAL         ) : REAL;
  2278.  
  2279. [PARAMETERS]
  2280.  
  2281. X       Hyperbolic CoSine Value
  2282.  
  2283. [RETURNS]
  2284.  
  2285. Arc Hyperbolic CoSine Angle
  2286.  
  2287. [DESCRIPTION]
  2288.  
  2289. Computes and returns the Arc Hyperbolic CoSine Angle of a given
  2290. Hyperbolic CoSine Value.
  2291.  
  2292. NOTE: The Hyperbolic CoSine Value is NOT Range Checked and MUST
  2293. be in Bounds.
  2294.  
  2295. [SEE-ALSO]
  2296.  
  2297. Sin2   Sinh   ArcSin    ArcSinh
  2298. Cos2   Cosh   ArcSin2   ArcTanh
  2299. Tan    Tanh   ArcCos    ArcCsch
  2300. Tan2          ArcCos2   ArcSech
  2301. Cot           ArcTan1   ArcCoth
  2302. Cot2          ArcTan2
  2303. Csc           ArcCsc
  2304. Sec           ArcSec
  2305.               ArcCot
  2306.  
  2307. [EXAMPLE]
  2308.  
  2309. VAR
  2310.   I : INTEGER;
  2311.   R : REAL;
  2312.  
  2313. BEGIN
  2314.  
  2315.   R := 1.0;
  2316.   For i := 100 DownTo 0 Do
  2317.   BEGIN
  2318.  
  2319.     WriteLn( 'ArcCosh(',R:0:0,') = ',ArcCosh( R ) :8:4 );
  2320.     R := R - 0.01;
  2321.  
  2322.   END;  { For i }
  2323.  
  2324. END;
  2325.  
  2326.  
  2327. ──────────────────────────────────────────────────────────────────────────────
  2328.  
  2329.  
  2330. [FUNCTION]
  2331.  
  2332. Function ArcTanh(            X     : REAL         ) : REAL;
  2333.  
  2334. [PARAMETERS]
  2335.  
  2336. X       Hyperbolic Tangent Value
  2337.  
  2338. [RETURNS]
  2339.  
  2340. Arc Hyperbolic Tangent Angle
  2341.  
  2342. [DESCRIPTION]
  2343.  
  2344. Computes and returns the Arc Hyperbolic Tangent Angle of a given
  2345. Hyperbolic Tangent Value.
  2346.  
  2347. [SEE-ALSO]
  2348.  
  2349. Sin2   Sinh   ArcSin    ArcSinh
  2350. Cos2   Cosh   ArcSin2   ArcCosh
  2351. Tan    Tanh   ArcCos    ArcCsch
  2352. Tan2          ArcCos2   ArcSech
  2353. Cot           ArcTan1   ArcCoth
  2354. Cot2          ArcTan2
  2355. Csc           ArcCsc
  2356. Sec           ArcSec
  2357.               ArcCot
  2358.  
  2359. [EXAMPLE]
  2360.  
  2361. VAR
  2362.   I : INTEGER;
  2363.   R : REAL;
  2364.  
  2365. BEGIN
  2366.  
  2367.   R := 1.0;
  2368.   For i := 100 DownTo 0 Do
  2369.   BEGIN
  2370.  
  2371.     WriteLn( 'ArcTanh(',R:0:0,') = ',ArcTanh( R ) :8:4 );
  2372.     R := R - 0.01;
  2373.  
  2374.   END;  { For i }
  2375.  
  2376. END;
  2377.  
  2378.  
  2379. ──────────────────────────────────────────────────────────────────────────────
  2380.  
  2381.  
  2382. [FUNCTION]
  2383.  
  2384. Function ArcCsch(            X     : REAL         ) : REAL;
  2385.  
  2386. [PARAMETERS]
  2387.  
  2388. X       Hyperbolic CoSecant Value
  2389.  
  2390. [RETURNS]
  2391.  
  2392. Arc Hyperbolic CoSecant Angle
  2393.  
  2394. [DESCRIPTION]
  2395.  
  2396. Computes and returns the Arc Hyperbolic CoSecant Angle of a given
  2397. Hyperbolic CoSecant Value.
  2398.  
  2399. NOTE: The Hyperbolic CoSecant Value is NOT Range Checked and MUST
  2400. be in Bounds.
  2401.  
  2402. [SEE-ALSO]
  2403.  
  2404. Sin2   Sinh   ArcSin    ArcSinh
  2405. Cos2   Cosh   ArcSin2   ArcCosh
  2406. Tan    Tanh   ArcCos    ArcTanh
  2407. Tan2          ArcCos2   ArcSech
  2408. Cot           ArcTan1   ArcCoth
  2409. Cot2          ArcTan2
  2410. Csc           ArcCsc
  2411. Sec           ArcSec
  2412.               ArcCot
  2413.  
  2414. [EXAMPLE]
  2415.  
  2416. VAR
  2417.   I : INTEGER;
  2418.   R : REAL;
  2419.  
  2420. BEGIN
  2421.  
  2422.   R := 1.0;
  2423.   For i := 100 DownTo 0 Do
  2424.   BEGIN
  2425.  
  2426.     WriteLn( 'ArcCsch(',R:0:0,') = ',ArcCsch( R ) :8:4 );
  2427.     R := R - 0.01;
  2428.  
  2429.   END;  { For i }
  2430.  
  2431. END;
  2432.  
  2433.  
  2434. ──────────────────────────────────────────────────────────────────────────────
  2435.  
  2436.  
  2437. [FUNCTION]
  2438.  
  2439. Function ArcSech(            X     : REAL         ) : REAL;
  2440.  
  2441. [PARAMETERS]
  2442.  
  2443. X       Hyperbolic Secant Value
  2444.  
  2445. [RETURNS]
  2446.  
  2447. Arc Hyperbolic Secant Angle
  2448.  
  2449. [DESCRIPTION]
  2450.  
  2451. Computes and returns the Arc Hyperbolic Secant Angle of a given
  2452. Hyperbolic Secant Value.
  2453.  
  2454. NOTE: The Hyperbolic Secant Value is NOT Range Checked and MUST
  2455. be in Bounds.
  2456.  
  2457. [SEE-ALSO]
  2458.  
  2459. Sin2   Sinh   ArcSin    ArcSinh
  2460. Cos2   Cosh   ArcSin2   ArcCosh
  2461. Tan    Tanh   ArcCos    ArcTanh
  2462. Tan2          ArcCos2   ArcCsch
  2463. Cot           ArcTan1   ArcCoth
  2464. Cot2          ArcTan2
  2465. Csc           ArcCsc
  2466. Sec           ArcSec
  2467.               ArcCot
  2468.  
  2469. [EXAMPLE]
  2470.  
  2471. VAR
  2472.   I : INTEGER;
  2473.   R : REAL;
  2474.  
  2475. BEGIN
  2476.  
  2477.   R := 1.0;
  2478.   For i := 100 DownTo 0 Do
  2479.   BEGIN
  2480.  
  2481.     WriteLn( 'ArcSech(',R:0:0,') = ',ArcSech( R ) :8:4 );
  2482.     R := R - 0.01;
  2483.  
  2484.   END;  { For i }
  2485.  
  2486. END;
  2487.  
  2488.  
  2489. ──────────────────────────────────────────────────────────────────────────────
  2490.  
  2491.  
  2492. [FUNCTION]
  2493.  
  2494. Function ArcCoth(            X     : REAL         ) : REAL;
  2495.  
  2496. [PARAMETERS]
  2497.  
  2498. X       Hyperbolic Tangent Value
  2499.  
  2500. [RETURNS]
  2501.  
  2502. Arc Hyperbolic Tangent Angle
  2503.  
  2504. [DESCRIPTION]
  2505.  
  2506. Computes and returns the Arc Hyperbolic Tangent Angle of a given
  2507. Hyperbolic Tangent Value.
  2508.  
  2509. [SEE-ALSO]
  2510.  
  2511. Sin2   Sinh   ArcSin    ArcSinh
  2512. Cos2   Cosh   ArcSin2   ArcCosh
  2513. Tan    Tanh   ArcCos    ArcTanh
  2514. Tan2          ArcCos2   ArcCsch
  2515. Cot           ArcTan1   ArcSech
  2516. Cot2          ArcTan2
  2517. Csc           ArcCsc
  2518. Sec           ArcSec
  2519.               ArcCot
  2520.  
  2521. [EXAMPLE]
  2522.  
  2523. VAR
  2524.   I : INTEGER;
  2525.   R : REAL;
  2526.  
  2527. BEGIN
  2528.  
  2529.   R := 1.0;
  2530.   For i := 100 DownTo 0 Do
  2531.   BEGIN
  2532.  
  2533.     WriteLn( 'ArcCoth(',R:0:0,') = ',ArcCoth( R ) :8:4 );
  2534.     R := R - 0.01;
  2535.  
  2536.   END;  { For i }
  2537.  
  2538. END;
  2539.  
  2540.  
  2541. ──────────────────────────────────────────────────────────────────────────────
  2542.  
  2543.  
  2544. [FUNCTION]
  2545.  
  2546. Function Power(              Num       : LONGINT;
  2547.                              Exponent  : LONGINT      ) : LONGINT;
  2548.  
  2549. [PARAMETERS]
  2550.  
  2551. Num         Number to Raise to Power
  2552. Exponent    Power to Raise Value by
  2553.  
  2554. [RETURNS]
  2555.  
  2556. Number Raised by a given Power
  2557.  
  2558. [DESCRIPTION]
  2559.  
  2560. Determines the Number Raised to a given Power.  Return the result
  2561. as a Long Integer Value.
  2562.  
  2563. [SEE-ALSO]
  2564.  
  2565. PowerR
  2566. Root
  2567. RootR
  2568.  
  2569. [EXAMPLE]
  2570.  
  2571. VAR
  2572.   Answer : REAL;
  2573.  
  2574. BEGIN
  2575.  
  2576.   Answer := PowerR( 7, 2 );  { Answer = 49 }
  2577.  
  2578. END;
  2579.  
  2580.  
  2581. ──────────────────────────────────────────────────────────────────────────────
  2582.  
  2583.  
  2584. [FUNCTION]
  2585.  
  2586. Function PowerR(             Num       : REAL;
  2587.                              Exponent  : REAL         ) : REAL;
  2588.  
  2589. [PARAMETERS]
  2590.  
  2591. Num         Number to Raise to a Power
  2592. Exponent    Power to Raise Number by
  2593.  
  2594. [RETURNS]
  2595.  
  2596. Number Raised by a given Power
  2597.  
  2598. [DESCRIPTION]
  2599.  
  2600. Determines the Number Raised by a given Power.  Returns the result
  2601. as a Floating Point Value.
  2602.  
  2603. [SEE-ALSO]
  2604.  
  2605. Power
  2606. Root
  2607. RootR
  2608.  
  2609. [EXAMPLE]
  2610.  
  2611. VAR
  2612.   Answer : REAL;
  2613.  
  2614. BEGIN
  2615.  
  2616.   Answer := PowerR( 7.0, 2.0 );  { Answer = 49.0 }
  2617.  
  2618. END;
  2619.  
  2620.  
  2621. ──────────────────────────────────────────────────────────────────────────────
  2622.  
  2623.  
  2624. [FUNCTION]
  2625.  
  2626. Function Root(               Num       : LONGINT;
  2627.                              RootVal   : LONGINT      ) : LONGINT;
  2628.  
  2629. [PARAMETERS]
  2630.  
  2631. Num         Number to get a Root from  (Must be > 0 or RunTime Error!)
  2632. RootVal     Root to apply to Number (can be any real number)
  2633.  
  2634. [RETURNS]
  2635.  
  2636. The Root Value of a given Number
  2637.  
  2638. [DESCRIPTION]
  2639.  
  2640. Computes the Root Value of a given Number.  The result is returned
  2641. as a Long Integer Value.
  2642.  
  2643. NOTE: Be sure that "Num" is Zero (0) or greater as imaginary Roots
  2644. and use of other Complex Numbers will cause a Runtime Error in this
  2645. Function.
  2646.  
  2647. [SEE-ALSO]
  2648.  
  2649. Power
  2650. PowerR
  2651. RootR
  2652.  
  2653. [EXAMPLE]
  2654.  
  2655. VAR
  2656.   Answer : LONGINT;
  2657.  
  2658. BEGIN
  2659.  
  2660.   Answer := Root( 49, 2 );  { Answer = 7 }
  2661.  
  2662. END;
  2663.  
  2664.  
  2665. ──────────────────────────────────────────────────────────────────────────────
  2666.  
  2667.  
  2668. [FUNCTION]
  2669.  
  2670. Function RootR(              Num       : REAL;
  2671.                              RootVal   : REAL         ) : REAL;
  2672.  
  2673. [PARAMETERS]
  2674.  
  2675. Num         Number to get a Root from  (Must be > 0 or RunTime Error!)
  2676. RootVal     Root to apply to Number (can be any real number)
  2677.  
  2678. [RETURNS]
  2679.  
  2680. The Root Value of a given Number
  2681.  
  2682. [DESCRIPTION]
  2683.  
  2684. Computes the Root Value of a given Number.  The result is returned
  2685. as a Floating Point Value.
  2686.  
  2687. NOTE: Be sure that "Num" is Zero (0) or greater as imaginary Roots
  2688. and use of other Complex Numbers will cause a Runtime Error in this
  2689. Function.
  2690.  
  2691. [SEE-ALSO]
  2692.  
  2693. Power
  2694. PowerR
  2695. Root
  2696.  
  2697. [EXAMPLE]
  2698.  
  2699. VAR
  2700.   Answer : REAL;
  2701.  
  2702. BEGIN
  2703.  
  2704.   Answer := RootR( 49.0, 2.0 );  { Answer = 7.0 }
  2705.  
  2706. END;
  2707.  
  2708.  
  2709. ──────────────────────────────────────────────────────────────────────────────
  2710.  
  2711.  
  2712. [FUNCTION]
  2713.  
  2714. Function Log(                Num       : REAL;
  2715.                              Base      : REAL         ) : REAL;
  2716.  
  2717. [PARAMETERS]
  2718.  
  2719. Num         Number to determine a Base of
  2720. Base        Base Value to use for Logarithm
  2721.  
  2722. [RETURNS]
  2723.  
  2724. Logarithm of a given Number.
  2725.  
  2726. [DESCRIPTION]
  2727.  
  2728. Computes a Logarithm of a given Number using a given Base.
  2729. To use "Natural" Logarithm use the Value from the Function E
  2730. as the Base.
  2731.  
  2732. The result is returned as a Floating Point Value.
  2733.  
  2734. [SEE-ALSO]
  2735.  
  2736. [EXAMPLE]
  2737.  
  2738. VAR
  2739.   Answer : REAL;
  2740.  
  2741. BEGIN
  2742.  
  2743.   Answer := Log( 32, 2 );  { Answer = 5.0 }
  2744.  
  2745. END;
  2746.  
  2747.  
  2748. ──────────────────────────────────────────────────────────────────────────────
  2749.  
  2750.  
  2751. [Function]
  2752.  
  2753. Function FastHyp(            XDist     : REAL;
  2754.                              YDist     : REAL        ) : REAL;
  2755.  
  2756. [PARAMETERS]
  2757.  
  2758. XDist       X Distance between Points
  2759. YDist       Y Distance between Points
  2760.  
  2761. [RETURNS]
  2762.  
  2763. The Hypotenuse of the X and Y Distances
  2764.  
  2765. [DESCRIPTION]
  2766.  
  2767. Computes and returns the Hypotenuse of the X and Y Distances
  2768. from another Point.  The main advantage of this routine is that
  2769. is does all the routines as simple Math functions thereby
  2770. reducing the computation time.
  2771.  
  2772. This method is useful in providing accept/reject distance tests
  2773. in 2D graphics.  These are commonly used in providing "Gravity
  2774. Fields" or other proximity tests for circle or ellipse selection.
  2775. This form is commony employed in libraries offering a high-precision
  2776. hypot as the conventional form is prone to severe loss of accuracy.
  2777.  
  2778. Note that the code is symmetric about the axis x = y = 1 within the
  2779. first quadrant.  Absolute value operation on the input arguments
  2780. allow for four-quadrant operation, yeilding isometric distance lines
  2781. of eight-fold symmetry.
  2782.  
  2783. [SEE-ALSO]
  2784.  
  2785. [EXAMPLE]
  2786.  
  2787.  
  2788. ──────────────────────────────────────────────────────────────────────────────
  2789.  
  2790.  
  2791. [Function]
  2792.  
  2793. Function FastHypR(           XDist     : REAL;
  2794.                              YDist     : REAL        ) : REAL;
  2795.  
  2796. [PARAMETERS]
  2797.  
  2798. XDist       X Distance between Points
  2799. YDist       Y Distance between Points
  2800.  
  2801. [RETURNS]
  2802.  
  2803. The Hypotenuse of the X and Y Distances
  2804.  
  2805. [DESCRIPTION]
  2806.  
  2807. Computes and returns the Hypotenuse of the X and Y Distances
  2808. from another Point.  The main advantage of this routine is that
  2809. is does all the routines as simple Math functions thereby
  2810. reducing the computation time.
  2811.  
  2812. This method is useful in providing accept/reject distance tests
  2813. in 2D graphics.  These are commonly used in providing "Gravity
  2814. Fields" or other proximity tests for circle or ellipse selection.
  2815. This form is commony employed in libraries offering a high-precision
  2816. hypot as the conventional form is prone to severe loss of accuracy.
  2817.  
  2818. Note that the code is symmetric about the axis x = y = 1 within the
  2819. first quadrant.  Absolute value operation on the input arguments
  2820. allow for four-quadrant operation, yeilding isometric distance lines
  2821. of eight-fold symmetry.
  2822.  
  2823. [SEE-ALSO]
  2824.  
  2825. [EXAMPLE]
  2826.  
  2827.  
  2828. ──────────────────────────────────────────────────────────────────────────────
  2829.  
  2830.  
  2831. [Function]
  2832.  
  2833. Function Hypot(              XDist     : REAL;
  2834.                              YDist     : REAL        ) : REAL;
  2835.  
  2836. [PARAMETERS]
  2837.  
  2838. XDist       X Distance between Points
  2839. YDist       Y Distance between Points
  2840.  
  2841. [RETURNS]
  2842.  
  2843. The Hypotenuse of the X and Y Distances
  2844.  
  2845. [DESCRIPTION]
  2846.  
  2847. Computes and returns the Hypotenuse of the X and Y Distances
  2848. from another Point.
  2849.  
  2850. [SEE-ALSO]
  2851.  
  2852. [EXAMPLE]
  2853.  
  2854.  
  2855. ──────────────────────────────────────────────────────────────────────────────
  2856.  
  2857.  
  2858. [FUNCTION]
  2859.  
  2860. Function FastDist(           X1        : LONGINT;
  2861.                              Y1        : LONGINT;
  2862.                              X2        : LONGINT;
  2863.                              Y2        : LONGINT      ) : LONGINT;
  2864.  
  2865. [PARAMETERS]
  2866.  
  2867. X1          X Coordinate of 1st Point
  2868. Y1          Y Coordinate of 1st Point
  2869. X2          X Coordinate of 2nd Point
  2870. Y2          Y Coordinate of 2nd Point
  2871.  
  2872. [RETURNS]
  2873.  
  2874. The Distance between the 2 Points (the Hypotenuse)
  2875.  
  2876. [DESCRIPTION]
  2877.  
  2878. Computes and returns the distance between 2 points whose Coordinates
  2879. are provided.
  2880.  
  2881. [SEE-ALSO]
  2882.  
  2883. Hypot
  2884.  
  2885. [EXAMPLE]
  2886.  
  2887. BEGIN
  2888.  
  2889.   WriteLn( 'Distance = ',Distance( 10,10, 20,20 ):8:4 );
  2890.  
  2891. END;
  2892.  
  2893.  
  2894. ──────────────────────────────────────────────────────────────────────────────
  2895.  
  2896.  
  2897. [FUNCTION]
  2898.  
  2899. Function DistanceXY(         X1        : REAL;
  2900.                              Y1        : REAL;
  2901.                              X2        : REAL;
  2902.                              Y2        : REAL         ) : REAL;
  2903.  
  2904. [PARAMETERS]
  2905.  
  2906. X1          X Coordinate of 1st Point
  2907. Y1          Y Coordinate of 1st Point
  2908. X2          X Coordinate of 2nd Point
  2909. Y2          Y Coordinate of 2nd Point
  2910.  
  2911. [RETURNS]
  2912.  
  2913. The Distance between the 2 Points (the Hypotenuse)
  2914.  
  2915. [DESCRIPTION]
  2916.  
  2917. Computes and returns the distance between 2 points whose Coordinates
  2918. are provided.
  2919.  
  2920. [SEE-ALSO]
  2921.  
  2922. Hypot
  2923.  
  2924. [EXAMPLE]
  2925.  
  2926. BEGIN
  2927.  
  2928.   WriteLn( 'Distance = ',Distance( 10,10, 20,20 ):8:4 );
  2929.  
  2930. END;
  2931.  
  2932.  
  2933. ──────────────────────────────────────────────────────────────────────────────
  2934.  
  2935.  
  2936. [FUNCTION]
  2937.  
  2938. Function Percent(            Part      : LONGINT;
  2939.                              Whole     : LONGINT      ) : REAL;
  2940.  
  2941. [PARAMETERS]
  2942.  
  2943. Part        Portion of the Whole being Referenced
  2944. Whole       Size representing 100% of Value
  2945.  
  2946. [RETURNS]
  2947.  
  2948. Percentage of 100% which Part represents
  2949.  
  2950. [DESCRIPTION]
  2951.  
  2952. Determines what percentage of the "Whole" Value the "Part" Value
  2953. represents.
  2954.  
  2955. [SEE-ALSO]
  2956.  
  2957. [EXAMPLE]
  2958.  
  2959. VAR
  2960.   Answer : REAL;
  2961.  
  2962. BEGIN
  2963.  
  2964.   Answer := Percent( 30.0, 60.0 );  { Answer = 50.0 }
  2965.  
  2966. END;
  2967.  
  2968.  
  2969. ──────────────────────────────────────────────────────────────────────────────
  2970.  
  2971.  
  2972. [FUNCTION]
  2973.  
  2974. Function Min(                A         : LONGINT;
  2975.                              B         : LONGINT      ) : LONGINT;
  2976.  
  2977. [PARAMETERS]
  2978.  
  2979. A           1st Source Value
  2980. B           2nd Source Value
  2981.  
  2982. [RETURNS]
  2983.  
  2984. The Lesser of the two Values
  2985.  
  2986. [DESCRIPTION]
  2987.  
  2988. Returns the Lesser of the Two Values as a Long Integer Value.
  2989.  
  2990. [SEE-ALSO]
  2991.  
  2992. MinR
  2993. Max
  2994. MaxR
  2995.  
  2996. [EXAMPLE]
  2997.  
  2998. VAR
  2999.   Answer : LONGINT;
  3000.  
  3001. BEGIN
  3002.  
  3003.   Answer := Min( 5, 3 );  { Answer = 3 }
  3004.  
  3005. END;
  3006.  
  3007.  
  3008. ──────────────────────────────────────────────────────────────────────────────
  3009.  
  3010.  
  3011. [FUNCTION]
  3012.  
  3013. Function MinR(               A         : REAL;
  3014.                              B         : REAL         ) : REAL;
  3015.  
  3016. [PARAMETERS]
  3017.  
  3018. A           1st Source Value
  3019. B           2nd Source Value
  3020.  
  3021. [RETURNS]
  3022.  
  3023. The Lesser of the two Values
  3024.  
  3025. [DESCRIPTION]
  3026.  
  3027. Returns the Lesser of the Two Values as a Floating Point Value.
  3028.  
  3029. [SEE-ALSO]
  3030.  
  3031. Min
  3032. Max
  3033. MaxR
  3034.  
  3035. [EXAMPLE]
  3036.  
  3037. VAR
  3038.   Answer : REAL;
  3039.  
  3040. BEGIN
  3041.  
  3042.   Answer := MinR( 5.2, 3.6 );  { Answer := 3.6 }
  3043.  
  3044. END;
  3045.  
  3046.  
  3047. ──────────────────────────────────────────────────────────────────────────────
  3048.  
  3049.  
  3050. [FUNCTION]
  3051.  
  3052. Function Max(                A         : LONGINT;
  3053.                              B         : LONGINT      ) : LONGINT;
  3054.  
  3055. [PARAMETERS]
  3056.  
  3057. A           1st Source Value
  3058. B           2nd Source Value
  3059.  
  3060. [RETURNS]
  3061.  
  3062. The Greater of the two Values
  3063.  
  3064. [DESCRIPTION]
  3065.  
  3066. Returns the Greater of the Two Values as a Long Integer Value.
  3067.  
  3068. [SEE-ALSO]
  3069.  
  3070. Min
  3071. MinR
  3072. MaxR
  3073.  
  3074. [EXAMPLE]
  3075.  
  3076. VAR
  3077.   Answer : LONGINT;
  3078.  
  3079. BEGIN
  3080.  
  3081.   Answer := Max( 5, 3 );  { Answer = 5 }
  3082.  
  3083. END;
  3084.  
  3085.  
  3086. ──────────────────────────────────────────────────────────────────────────────
  3087.  
  3088.  
  3089. [FUNCTION]
  3090.  
  3091. Function MaxR(               A         : REAL;
  3092.                              B         : REAL         ) : REAL;
  3093.  
  3094. [PARAMETERS]
  3095.  
  3096. A           1st Source Value
  3097. B           2nd Source Value
  3098.  
  3099. [RETURNS]
  3100.  
  3101. The Greater of the two Values
  3102.  
  3103. [DESCRIPTION]
  3104.  
  3105. Returns the Greater of the Two Values as a Floating Point Value.
  3106.  
  3107. [SEE-ALSO]
  3108.  
  3109. Min
  3110. MinR
  3111. Max
  3112.  
  3113. [EXAMPLE]
  3114.  
  3115. VAR
  3116.   Answer : REAL;
  3117.  
  3118. BEGIN
  3119.  
  3120.   Answer := MaxR( 5.2, 3.6 );  { Answer = 5.2 }
  3121.  
  3122. END;
  3123.  
  3124.  
  3125. ──────────────────────────────────────────────────────────────────────────────
  3126.  
  3127.  
  3128. [FUNCTION]
  3129.  
  3130. Function Range(              Num       : LONGINT;
  3131.                              Low       : LONGINT;
  3132.                              High      : LONGINT      ) : LONGINT;
  3133.  
  3134. [PARAMETERS]
  3135.  
  3136. Num         Source Value to Range Check
  3137. Low         Minimum Limit
  3138. High        Maximum Limit
  3139.  
  3140. [RETURNS]
  3141.  
  3142. The Value Clipped by the Range
  3143.  
  3144. [DESCRIPTION]
  3145.  
  3146. Range Checks a Value and Clips it to within the given Minimum
  3147. and Maximum Range.  Result is returned as a Long Integer Value.
  3148.  
  3149. [SEE-ALSO]
  3150.  
  3151. RangeR
  3152. Floor
  3153. FloorR
  3154. Ceiling
  3155. CeilingR
  3156.  
  3157. [EXAMPLE]
  3158.  
  3159. VAR
  3160.   Answer : LONGINT;
  3161.  
  3162. BEGIN
  3163.  
  3164.   Answer := RangeR( 43 ,40, 50 );  { Answer = 43 }
  3165.   Answer := RangeR( 37 ,40, 50 );  { Answer = 40 }
  3166.   Answer := RangeR( 73 ,40, 50 );  { Answer = 50 }
  3167.  
  3168. END;
  3169.  
  3170.  
  3171. ──────────────────────────────────────────────────────────────────────────────
  3172.  
  3173.  
  3174. [FUNCTION]
  3175.  
  3176. Function RangeR(             Num       : REAL;
  3177.                              Low       : REAL;
  3178.                              High      : REAL         ) : REAL;
  3179.  
  3180. [PARAMETERS]
  3181.  
  3182. Num         Source Value to Range Check
  3183. Low         Minimum Limit
  3184. High        Maximum Limit
  3185.  
  3186. [RETURNS]
  3187.  
  3188. The Value Clipped by the Range
  3189.  
  3190. [DESCRIPTION]
  3191.  
  3192. Range Checks a Value and Clips it to within the given Minimum
  3193. and Maximum Range.  Result is returned as a Floating Point Value.
  3194.  
  3195. [SEE-ALSO]
  3196.  
  3197. Range
  3198. Floor
  3199. FloorR
  3200. Ceiling
  3201. CeilingR
  3202.  
  3203. [EXAMPLE]
  3204.  
  3205. VAR
  3206.   Answer : REAL;
  3207.  
  3208. BEGIN
  3209.  
  3210.   Answer := RangeR( 43.6 ,40.0, 50.0 );  { Answer = 43.6 }
  3211.   Answer := RangeR( 37.2 ,40.0, 50.0 );  { Answer = 40.0 }
  3212.   Answer := RangeR( 73.3 ,40.0, 50.0 );  { Answer = 50.0 }
  3213.  
  3214. END;
  3215.  
  3216.  
  3217. ──────────────────────────────────────────────────────────────────────────────
  3218.  
  3219.  
  3220. [FUNCTION]
  3221.  
  3222. Function Floor(              Num       : LONGINT;
  3223.                              Low       : LONGINT      ) : LONGINT;
  3224.  
  3225. [PARAMETERS]
  3226.  
  3227. Num         Source Value to Range Check
  3228. Low         Minimum Limit
  3229.  
  3230. [RETURNS]
  3231.  
  3232. The Value Clipped by the Minimum Range
  3233.  
  3234. [DESCRIPTION]
  3235.  
  3236. Range Checks a Value and Clips it so it is at or above a given
  3237. Minimum Range.  The result is returned as a Long Integer Value.
  3238.  
  3239. [SEE-ALSO]
  3240.  
  3241. Range
  3242. RangeR
  3243. FloorR
  3244. Ceiling
  3245. CeilingR
  3246.  
  3247. [EXAMPLE]
  3248.  
  3249. VAR
  3250.   Answer : LONGINT;
  3251.  
  3252. BEGIN
  3253.  
  3254.   Answer := Floor( 33, 25 );  { Answer = 33 }
  3255.   Answer := Floor( 17, 25 );  { Answer = 25 }
  3256.  
  3257. END;
  3258.  
  3259.  
  3260. ──────────────────────────────────────────────────────────────────────────────
  3261.  
  3262.  
  3263. [FUNCTION]
  3264.  
  3265. Function FloorR(             Num       : REAL;
  3266.                              Low       : REAL         ) : REAL;
  3267.  
  3268. [PARAMETERS]
  3269.  
  3270. Num         Source Value to Range Check
  3271. Low         Minimum Limit
  3272.  
  3273. [RETURNS]
  3274.  
  3275. The Value Clipped by the Minimum Range
  3276.  
  3277. [DESCRIPTION]
  3278.  
  3279. Range Checks a Value and Clips it so it is at or above a given
  3280. Minimum Range.  The result is returned as a Floating Point Value.
  3281.  
  3282. [SEE-ALSO]
  3283.  
  3284. Range
  3285. RangeR
  3286. Floor
  3287. Ceiling
  3288. CeilingR
  3289.  
  3290. [EXAMPLE]
  3291.  
  3292. VAR
  3293.   Answer : REAL;
  3294.  
  3295. BEGIN
  3296.  
  3297.   Answer := FloorR( 22.5, 20.0 );  { Answer = 22.5 }
  3298.   Answer := FloorR( 17.5, 20.0 );  { Answer = 20.0 }
  3299.  
  3300. END;
  3301.  
  3302.  
  3303. ──────────────────────────────────────────────────────────────────────────────
  3304.  
  3305.  
  3306. [FUNCTION]
  3307.  
  3308. Function Ceiling(            Num       : LONGINT;
  3309.                              High      : LONGINT      ) : LONGINT;
  3310.  
  3311. [PARAMETERS]
  3312.  
  3313. Num         Source Value to Range Check
  3314. High        Maximum Limit
  3315.  
  3316. [RETURNS]
  3317.  
  3318. The Value Clipped by the Maximum Range
  3319.  
  3320. [DESCRIPTION]
  3321.  
  3322. Range Checks a Value and Clips it so it is at or above a given
  3323. Maximum Range.  The result is returned as a Long Integer Value.
  3324.  
  3325. [SEE-ALSO]
  3326.  
  3327. Range
  3328. RangeR
  3329. Floor
  3330. FloorR
  3331. CeilingR
  3332.  
  3333. [EXAMPLE]
  3334.  
  3335. VAR
  3336.   Answer : LONGINT;
  3337.  
  3338. BEGIN
  3339.  
  3340.   Answer := Ceiling( 32, 40 );  { Answer = 32 }
  3341.   Answer := Ceiling( 45, 40 );  { Answer = 40 }
  3342.  
  3343. END;
  3344.  
  3345.  
  3346. ──────────────────────────────────────────────────────────────────────────────
  3347.  
  3348.  
  3349. [FUNCTION]
  3350.  
  3351. Function CeilingR(           Num       : REAL;
  3352.                              High      : REAL         ) : REAL;
  3353.  
  3354. [PARAMETERS]
  3355.  
  3356. Num         Source Value to Range Check
  3357. High        Maximum Limit
  3358.  
  3359. [RETURNS]
  3360.  
  3361. The Value Clipped by the Maximum Range
  3362.  
  3363. [DESCRIPTION]
  3364.  
  3365. Range Checks a Value and Clips it so it is at or above a given
  3366. Maximum Range.  The result is returned as a Floating Point Value.
  3367.  
  3368. [SEE-ALSO]
  3369.  
  3370. Range
  3371. RangeR
  3372. Floor
  3373. FloorR
  3374. Ceiling
  3375.  
  3376. [EXAMPLE]
  3377.  
  3378. VAR
  3379.   Answer : REAL;
  3380.  
  3381. BEGIN
  3382.  
  3383.   Answer := Ceiling(  95.2, 100.0 );  { Answer :=  95.2 }
  3384.   Answer := Ceiling( 104.5, 100.0 );  { Answer := 100.0 }
  3385.  
  3386. END;
  3387.  
  3388.  
  3389. ──────────────────────────────────────────────────────────────────────────────
  3390.  
  3391.  
  3392. [FUNCTION]
  3393.  
  3394. Function Sign(               Num       : LONGINT      ) : INTEGER;
  3395.  
  3396. [PARAMETERS]
  3397.  
  3398. Num         Source Value
  3399.  
  3400. [RETURNS]
  3401.  
  3402. The Value's Sign (+1 if >= 0, or -1 if < 0 )
  3403.  
  3404. [DESCRIPTION]
  3405.  
  3406. Determines the sign of the Source Value.  If it is Greater or Equal
  3407. to Zero, then it is +1.  If it is Less than Zero, then it is -1.
  3408. The result is returned as a Long Integer Value.
  3409.  
  3410. [SEE-ALSO]
  3411.  
  3412. [EXAMPLE]
  3413.  
  3414. VAR
  3415.   Answer : INTEGER;
  3416.  
  3417. BEGIN
  3418.  
  3419.   Answer := Sign( 100 );  { Answer = +1 }
  3420.  
  3421. END;
  3422.  
  3423.  
  3424. ──────────────────────────────────────────────────────────────────────────────
  3425.  
  3426.  
  3427. [FUNCTION]
  3428.  
  3429. Function SignR(              Num       : LONGINT      ) : INTEGER;
  3430.  
  3431. [PARAMETERS]
  3432.  
  3433. Num         Source Value
  3434.  
  3435. [RETURNS]
  3436.  
  3437. The Value's Sign (+1 if >= 0, or -1 if < 0 )
  3438.  
  3439. [DESCRIPTION]
  3440.  
  3441. Determines the sign of the Source Value.  If it is Greater or Equal
  3442. to Zero, then it is +1.  If it is Less than Zero, then it is -1.
  3443. The result is returned as a Floating Point Value.
  3444.  
  3445. [SEE-ALSO]
  3446.  
  3447. Sign
  3448.  
  3449. [EXAMPLE]
  3450.  
  3451. VAR
  3452.   Answer : INTEGER;
  3453.  
  3454. BEGIN
  3455.  
  3456.   Answer := SignR( -32.6 );  { Answer = -1 }
  3457.  
  3458. END;
  3459.  
  3460.  
  3461. ──────────────────────────────────────────────────────────────────────────────
  3462.  
  3463.  
  3464. [FUNCTION]
  3465.  
  3466. Function QuadraticPlus(      A         : LONGINT;
  3467.                              B         : LONGINT;
  3468.                              C         : LONGINT      ) : REAL;
  3469.  
  3470. [PARAMETERS]
  3471.  
  3472. A           1st Polynomial Position Value
  3473. B           2nd Polynomial Position Value
  3474. C           3rd Polynomial Position Value
  3475.  
  3476. [RETURNS]
  3477.  
  3478. Positive Quadratic Solution in Terms of X
  3479.  
  3480. [DESCRIPTION]
  3481.  
  3482. Computes the Quadratic of y = Ax^2 + Bx + C in terms of X with
  3483. only the Positive Answer returned.
  3484.  
  3485. [SEE-ALSO]
  3486.  
  3487. QuadraticNeg
  3488.  
  3489. [EXAMPLE]
  3490.  
  3491. VAR
  3492.   X : REAL;
  3493.  
  3494. BEGIN
  3495.  
  3496.   X := QuadraticPlus( 2, 8, 4 );  { X = -0.5858 }
  3497.  
  3498. END;
  3499.  
  3500.  
  3501. ──────────────────────────────────────────────────────────────────────────────
  3502.  
  3503.  
  3504. [FUNCTION]
  3505.  
  3506. Function QuadraticNeg(       A         : LONGINT;
  3507.                              B         : LONGINT;
  3508.                              C         : LONGINT      ) : REAL;
  3509.  
  3510. [PARAMETERS]
  3511.  
  3512. A           1st Polynomial Position Value
  3513. B           2nd Polynomial Position Value
  3514. C           3rd Polynomial Position Value
  3515.  
  3516. [RETURNS]
  3517.  
  3518. Negative Quadratic Solution in Terms of X
  3519.  
  3520. [DESCRIPTION]
  3521.  
  3522. Computes the Quadratic of y = Ax^2 + Bx + C in terms of X with
  3523. only the Negative Answer returned.
  3524.  
  3525. [SEE-ALSO]
  3526.  
  3527. QuadraticPlus
  3528.  
  3529. [EXAMPLE]
  3530.  
  3531. VAR
  3532.   X : REAL;
  3533.  
  3534. BEGIN
  3535.  
  3536.   X := QuadraticNeg( 2, 8, 4 );  { X = -3.4142}
  3537.  
  3538. END;
  3539.  
  3540.  
  3541. ──────────────────────────────────────────────────────────────────────────────
  3542.  
  3543.  
  3544. [FUNCTION]
  3545.  
  3546. Function Factorial(           N         : BYTE         ) : REAL;
  3547.  
  3548.  
  3549. [PARAMETERS]
  3550.  
  3551. N           Natural Number to Factor
  3552.  
  3553. [RETURNS]
  3554.  
  3555. Factorial Product
  3556.  
  3557. [DESCRIPTION]
  3558.  
  3559. Returns the Factorial Product of a Number.  N=33 is the Maximum
  3560. for real type answers.
  3561.  
  3562. [SEE-ALSO]
  3563.  
  3564. [EXAMPLE]
  3565.  
  3566. VAR
  3567.   Answer : REAL;
  3568.  
  3569. BEGIN
  3570.  
  3571.   Answer := Factorial(   2 );  { Answer =         2.0000 }
  3572.   Answer := Factorial(   4 );  { Answer =        24.0000 }
  3573.   Answer := Factorial(   6 );  { Answer =       720.0000 }
  3574.   Answer := Factorial(  12 );  { Answer = 479001600.0000 }
  3575.   Answer := Factorial(  36 );  { Answer =         1.0000 }
  3576.   Answer := Factorial( 100 );  { Answer =         1.0000 }
  3577.  
  3578. END;
  3579.  
  3580.  
  3581. ──────────────────────────────────────────────────────────────────────────────
  3582.  
  3583.  
  3584. [FUNCTION]
  3585.  
  3586. Function Permu(              N         : BYTE;
  3587.                              R         : BYTE         ) : REAL;
  3588.  
  3589. [PARAMETERS]
  3590.  
  3591. N           Number of Objects to Use
  3592. R           Use R at a Time (for each Permutation)
  3593.  
  3594. [RETURNS]
  3595.  
  3596. Permutation Product
  3597.  
  3598. [DESCRIPTION]
  3599.  
  3600. Returns the number of permutations of "N" Objects taken "R"
  3601. at a time, which means a listing or an arrangement of R of
  3602. the Objects in a definite order, where R <= N.  The number
  3603. of such arrangements is denoted by P(n,r).
  3604.  
  3605. [SEE-ALSO]
  3606.  
  3607. Combo
  3608.  
  3609. [EXAMPLE]
  3610.  
  3611. VAR
  3612.   Answer : REAL;
  3613.  
  3614. BEGIN
  3615.  
  3616.   Answer := Permu( 12, 2 );  { Answer =   134 }
  3617.   Answer := Permu( 12, 3 );  { Answer =  1340 }
  3618.   Answer := Permu( 12, 4 );  { Answer = 11880 }
  3619.   Answer := Permu( 12, 5 );  { Answer = 95040 }
  3620.  
  3621. END;
  3622.  
  3623.  
  3624. ──────────────────────────────────────────────────────────────────────────────
  3625.  
  3626.  
  3627. [FUNCTION]
  3628.  
  3629. Function Combo(              N         : BYTE;
  3630.                              R         : BYTE         ) : REAL;
  3631.  
  3632. [PARAMETERS]
  3633.  
  3634. N           Number of Objects to Use
  3635. R           Use R at a Time (for each combination)
  3636.  
  3637. [RETURNS]
  3638.  
  3639. Combination Product
  3640.  
  3641. [DESCRIPTION]
  3642.  
  3643. Returns the selection or subset of "R" Objects from a set of
  3644. "N" Objects, where R <= N.  The number of such combinations
  3645. is denoted C(n,r).
  3646.  
  3647. [SEE-ALSO]
  3648.  
  3649. Permu
  3650.  
  3651. [EXAMPLE]
  3652.  
  3653. VAR
  3654.   Answer : REAL;
  3655.  
  3656. BEGIN
  3657.  
  3658.   Answer := Combo( 12, 2 );  { Answer =  66 }
  3659.   Answer := Combo( 12, 3 );  { Answer = 220 }
  3660.   Answer := Combo( 12, 4 );  { Answer = 495 }
  3661.   Answer := Combo( 12, 5 );  { Answer = 792 }
  3662.  
  3663.  
  3664. END;
  3665.  
  3666.  
  3667. ──────────────────────────────────────────────────────────────────────────────
  3668.  
  3669.  
  3670. [FUNCTION]
  3671.  
  3672. Function Prime(              N         : LONGINT      ) : BOOLEAN;
  3673.  
  3674. [PARAMETERS]
  3675.  
  3676. N           Number to Check that it is a Prime Number
  3677.  
  3678. [RETURNS]
  3679.  
  3680. Whether or not this Number was a Prime Nmuber
  3681.  
  3682. [DESCRIPTION]
  3683.  
  3684. Determines if this number was a Prime Number and returns the result.
  3685.  
  3686. [SEE-ALSO]
  3687.  
  3688. [EXAMPLE]
  3689.  
  3690. BEGIN
  3691.  
  3692.   WriteLn( 'Prime( 3)=',Prime( 3) );  { TRUE  }
  3693.   WriteLn( 'Prime( 6)=',Prime( 6) );  { FALSE }
  3694.   WriteLn( 'Prime(15)=',Prime(15) );  { FALSE }
  3695.   WriteLn( 'Prime(23)=',Prime(23) );  { TRUE  }
  3696.  
  3697. END;
  3698.  
  3699.  
  3700. ──────────────────────────────────────────────────────────────────────────────
  3701.  
  3702.  
  3703. [FUNCTION]
  3704.  
  3705. Function GCF(                A         : LONGINT;
  3706.                              B         : LONGINT      ) : LONGINT;
  3707.  
  3708. [PARAMETERS]
  3709.  
  3710. A           1st Source Number
  3711. B           2nd Source Number
  3712.  
  3713. [RETURNS]
  3714.  
  3715. The Greatest Common Factor of the two numbers.
  3716.  
  3717. [DESCRIPTION]
  3718.  
  3719. Determines the Greatest Common Factor between the two given
  3720. numbers.
  3721.  
  3722. [SEE-ALSO]
  3723.  
  3724. LCM
  3725.  
  3726. [EXAMPLE]
  3727.  
  3728. VAR
  3729.   Answer : LONGINT;
  3730.  
  3731. BEGIN
  3732.  
  3733.   Answer := GCF( 6, 9 );
  3734.  
  3735.   { Answer := 3 }
  3736.  
  3737. END;
  3738.  
  3739.  
  3740. ──────────────────────────────────────────────────────────────────────────────
  3741.  
  3742.  
  3743. [FUNCTION]
  3744.  
  3745. Function LCM(                A         : LONGINT;
  3746.                              B         : LONGINT      ) : LONGINT;
  3747.  
  3748. [PARAMETERS]
  3749.  
  3750. A           1st Source Number
  3751. B           2nd Source Number
  3752.  
  3753. [RETURNS]
  3754.  
  3755. The Least Common Multiple of the two numbers.
  3756.  
  3757. [DESCRIPTION]
  3758.  
  3759. Determines the Least Common Multiple between the two given
  3760. Numbers.
  3761.  
  3762. [SEE-ALSO]
  3763.  
  3764. GCF
  3765.  
  3766. [EXAMPLE]
  3767.  
  3768. VAR
  3769.   Answer : LONGINT;
  3770.  
  3771. BEGIN
  3772.  
  3773.   Answer := LCM( 36, 54 );
  3774.  
  3775.   { Answer = 108 }
  3776.  
  3777. END;
  3778.  
  3779.  
  3780. ──────────────────────────────────────────────────────────────────────────────
  3781.  
  3782.  
  3783. [FUNCTION]
  3784.  
  3785. Procedure LoadArrayR( VAR Arr : PArrayR;
  3786.                           Idx : WORD;
  3787.                           R   : REAL  );
  3788.  
  3789. [PARAMETERS]
  3790.  
  3791. Arr         Pointer to Linear Data Array
  3792. Idx         Number of Elements in the Data Array
  3793. R           Value to set Element to
  3794.  
  3795. [RETURNS]
  3796.  
  3797. (Function : None)
  3798. (VAR      : Pointer to Linear Data Array w/ Data Modified)
  3799.  
  3800. [DESCRIPTION]
  3801.  
  3802. Loads the Data Array's Indexed Element to the Provided Value
  3803. Use this Procedure to quickly Load the Data Array Values for the
  3804. Coordinate Record at a specific Index.
  3805.  
  3806. [SEE-ALSO]
  3807.  
  3808. LoadArrayRXY
  3809.  
  3810. [EXAMPLE]
  3811.  
  3812. VAR
  3813.   Arr : PArrayR;
  3814.  
  3815. BEGIN
  3816.  
  3817.   LoadArrayR( Arr, 3, 97.5 );
  3818.  
  3819.   { Element in "Arr" at Index 3 now equals 97.5 }
  3820.  
  3821. END;
  3822.  
  3823.  
  3824. ──────────────────────────────────────────────────────────────────────────────
  3825.  
  3826.  
  3827. [FUNCTION]
  3828.  
  3829. Procedure LoadArrayRXY( VAR Arr : PArray2R;
  3830.                             Idx : WORD;
  3831.                             X   : REAL;
  3832.                             Y   : REAL  );
  3833.  
  3834. [PARAMETERS]
  3835.  
  3836. Arr         Pointer to Linear Data Array or Coordinates
  3837. Idx         Number of Elements in the Data Array
  3838. X           Value to Set X-Element To
  3839. Y           Value to Set Y-Element To
  3840.  
  3841. [RETURNS]
  3842.  
  3843. (Function : None)
  3844. (VAR      : Pointer to Linear Data Array w/ Data Modified)
  3845.  
  3846. [DESCRIPTION]
  3847.  
  3848. Loads the Data Array's Indexed Elements (X & Y) to the Provided Values.
  3849. Use this Procedure to quickly Load the Data Array Values for the
  3850. Coordinate Record at a specific Index.
  3851.  
  3852. [SEE-ALSO]
  3853.  
  3854. LoadArrayR
  3855.  
  3856. [EXAMPLE]
  3857.  
  3858. VAR
  3859.   Arr : PArray2R;
  3860.  
  3861. BEGIN
  3862.  
  3863.   LoadArrayRXY( Arr, 5, 2.5, 3.7 );
  3864.  
  3865.   { Record in "Arr" at Index now contains X=2.5 and Y=3.7 }
  3866.  
  3867. END;
  3868.  
  3869.  
  3870. ──────────────────────────────────────────────────────────────────────────────
  3871.  
  3872.  
  3873. [FUNCTION]
  3874.  
  3875. Procedure MeanStdDev( Arr    : PArrayR;  { Data Array }
  3876.                       Cnt    : INTEGER;  { Data Count }
  3877.                   VAR Mean   : REAL;     { Mean }
  3878.                   VAR StdDev : REAL );   { Standard Deviation }
  3879.  
  3880. [PARAMETERS]
  3881.  
  3882. Arr         Pointer to Linear Data Array
  3883. Cnt         Number of Elements in Linear Data Array
  3884. Mean        VAR Returned Mean Value of Dispursion
  3885. StdDev      VAR Returned Standard Deviation of Dispursion
  3886.  
  3887. [RETURNS]
  3888.  
  3889. (Function : None)
  3890. (VAR      : [Mean] Returned Mean Value of Dispursion)
  3891. (VAR      : [StdDev] Returned Standard Deviation of Dispursion)
  3892.  
  3893. [DESCRIPTION]
  3894.  
  3895. Takes a List of Values and determines what the Mean [Middle] Dispersion
  3896. Value is and what the Dispursion Deviation is.
  3897.  
  3898. [SEE-ALSO]
  3899.  
  3900. [EXAMPLE]
  3901.  
  3902. VAR
  3903.   Arr    : PArrayR;
  3904.   Mean,
  3905.   StdDev : REAL;
  3906.  
  3907. BEGIN
  3908.   LoadArray( Arr, 1, 1 );
  3909.   LoadArray( Arr, 2, 2 );
  3910.   LoadArray( Arr, 3, 3 );
  3911.   LoadArray( Arr, 4, 4 );
  3912.   LoadArray( Arr, 5, 5 );
  3913.  
  3914.   MeanStdDev( Arr, 5, Mean, StdDev );
  3915.  
  3916.   { Mean = 3.000,  StdDev = 1.5811 }
  3917.  
  3918. END.
  3919.  
  3920.  
  3921. ──────────────────────────────────────────────────────────────────────────────
  3922.  
  3923.  
  3924. [FUNCTION]
  3925.  
  3926. Function Sigma( Arr : PArrayR;
  3927.                 Cnt : INTEGER ) : REAL;
  3928.  
  3929. [PARAMETERS]
  3930.  
  3931. Arr         Pointer to Linear Data Array
  3932. Cnt         Number of Elements in Data Array
  3933.  
  3934. [RETURNS]
  3935.  
  3936. The Sigma Summation of the Data Values
  3937.  
  3938. [DESCRIPTION]
  3939.  
  3940. Calculates the Sigma Summation of the Data Provided.
  3941.  
  3942. [SEE-ALSO]
  3943.  
  3944. [EXAMPLE]
  3945.  
  3946.  
  3947. ──────────────────────────────────────────────────────────────────────────────
  3948.  
  3949.  
  3950. [FUNCTION]
  3951.  
  3952. Procedure LeastSqr( Arr   : PArray2R; { Data Array }
  3953.                     Cnt   : INTEGER;  { Data Count }
  3954.                 VAR YInt  : REAL;     { Y-Intercept }
  3955.                 VAR Slope : REAL );   { Slope }
  3956.  
  3957. [PARAMETERS]
  3958.  
  3959. Arr         Pointer to Linear Array of Point Coordinate Data
  3960. Cnt         Number of Coordinates in Array
  3961. YInt        VAR Returned Y-Intercept Solution
  3962. Slope       VAR Returned Line Slope Solution
  3963.  
  3964. [RETURNS]
  3965.  
  3966. (Function : None)
  3967. (VAR      : [YInt] Returned Y-Intercept Solution)
  3968. (VAR      : [Slope] Returned Line Slope Solution)
  3969.  
  3970. [DESCRIPTION]
  3971.  
  3972. Does a Least Squares Line Fitting Algorithm on the Point Data
  3973. and determines the Line Solution's Y-Intercept and Slope (expressed
  3974. as a Tangent Value - ArcTan returns Angle).
  3975.  
  3976. To Construct resulting Line use the Algorithm
  3977.  
  3978.               y = Slope * x + YInt;
  3979.  
  3980. [SEE-ALSO]
  3981.  
  3982. (None)
  3983.  
  3984. [EXAMPLES]
  3985.  
  3986. VAR
  3987.   Arr   : PArray2RA;
  3988.   YInt,
  3989.   Slope : REAL;
  3990.  
  3991. BEGIN
  3992.  
  3993.   LoadArrayRXY( Arr, 1, 1, 2 );
  3994.   LoadArrayRXY( Arr, 2, 2, 3 );
  3995.   LoadArrayRXY( Arr, 3, 3, 4 );
  3996.   LoadArrayRXY( Arr, 4, 4, 5 );
  3997.   LoadArrayRXY( Arr, 5, 5, 6 );
  3998.   LoadArrayRXY( Arr, 6, 6, 7 );
  3999.  
  4000.   LeastSqr( Arr, 6, YInt, Slope );
  4001.  
  4002.   { YInt = 1.0, Slope = 1.0[Tan] (45deg) }
  4003.  
  4004. END;
  4005.  
  4006.